Wednesday, September 28, 2011

What is the difference among include() vs. require() or include_once() vs. require_once()?

include() and require() allow you to insert a file multiple times within a single execution lifetime. On the other hand, include_once() and require_once() make sure one file is inserted only once in a single execution lifetime, even if the code calls them multiple times.

If PHP interpreter fails to include a file in response to a call of include() or include_once(), a Warning is generated and execution continues without that file whereas failure to include a file called by require() or require_once() generates a Fatal Error and execution stops immediately.

No comments :