PHP: The difference between include and require function


Basically, the two functions (include and require) are executed the same: PHP will load the entire contents of the file include or require, no matter what the format. For content in php tags will be executed as normal php file. For content outside of php tags will be printed.

The difference between the two functions:
include(“file.php”): if the file does not exist file.php it will automatically execute the script again.
require(“file.php”): if the file does not exist, it will stand always file.php and execute any script that does the following. Therefore the require file is the most important file.
include_once like include, however include_once include only one single time.
require_once like require, however require_once only require one single time.

Related Post

, , , ,

No comments yet.

Leave a Reply