the difference between require and require_once. I just want to know the difference rather than Warning and Fatal Error in php.
Asked
Active
Viewed 2.3k times
2
-
1require_once is slower. Whether or not the difference will be significant depends on your particular code. – Dave Jan 09 '15 at 19:08
-
if you search that question at google you would get lots of answer – Shaiful Islam Jan 09 '15 at 19:17
1 Answers
29
require()
includes and evaluates a specific file, while require_once()
does that only if it has not been included before (on the same page).
So, require_once()
is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.