The include() statement includes
and evaluates the specified file.The documentation below also applies torequire(). The two constructs are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, userequire() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless.
The include_once()
statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. As the name suggests, it will be included just once.include_once() should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc.
require_once()
should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc. |
Oct 15, 2014
What are the differences between require and include, include_once and require_once?
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment