July 26, 2017

Core PHP: Include & Require (5.19)

include vs require


The require statement is identical to include, the exception being that, upon failure, it produces a fatal error.
When a file is included using the include statement, but PHP is unable to find it, the script continues to execute.
In the case of require, the script will cease execution and produce an error.

Use require when the file is required for the application to run.
Use include when the file is not required. The application should continue, even when the file is not found.

No comments:

Post a Comment