The require () function refers to the inclusion of the content as a part of the current file, so when the included file has a syntax error or the file does not exist, the current file of the PHP script is no longer executed.
The include () function is the equivalent of specifying the path to the file, which does not affect the program's operation when the contained file is in error.
First of all, in the include and require two literal meaning to realize! Include is included , require is needed !
It is easy to see the tone of emphasis is not the same! Require error report the program behind the error is not executing!
Include error is reported Waring! The following program continues execution!
And of course their derivative: include_once () require_once ();
PHP's official PHP manual for explanations
Require and include
almost exactly the same , in addition to handling the failure in a different way. Require
E_compile_error
Level of error. In other words will cause the script to abort and include
Only the warning (e_warning) is generated and the script continues to run.
Official explanation:
Require is identical to include except upon failure it would also produce a fatal e_compile_error level ERROR. In other words, it'll halt the script whereas include only emits a warning (e_warning
The difference between include and require