the difference between require and require_once. I just want to know the difference rather than Warning and Fatal Error in php.
-
um........what? – ElGavilan Jan 9 '15 at 19:07
-
1require_once is slower. Whether or not the difference will be significant depends on your particular code. – Dave Jan 9 '15 at 19:08
-
if you search that question at google you would get lots of answer – Shaiful Islam Jan 9 '15 at 19:17
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.