PHP upgrade-includeInclude and require statements are used to insert useful code into other files in the execution stream. Include is very similar to require, except for the difference in error handling. Require will generate a fatal error (E_COMPILE_ERROR) and stop the script. include will only generate a warning (E_WARNING), and the script will continue. 1. Require
PHP upgrade-include Include and require statements are used to insert useful code into other files in the execution stream. Include is very similar to require, except for the difference in error handling. Require will generate a fatal error (E_COMPILE_ERROR) and stop the script. include will only generate a warning (E_WARNING), and the script will continue. 1. Require
PHP upgrade-include
The Include and require statements are used to insert useful code into other files in the execution stream.
Include is similar to require except for differences in error handling.
Require will generate a fatal error (E_COMPILE_ERROR) and stop the script. include will only generate a warning (E_WARNING), and the script will continue.
1. The differences between Require, require_once, include, and include_once.
Require (): contains and runs the specified file.
Include (): Include and run the specified file.
Require_once (): contains and runs the specified file. If the target file already exists, it is not included. It is similar to the require () statement.
Include_once (): contains and runs the specified file. If the target file already exists, it is not included. It is similar to include.
2. Difference Between Require () and require_once ()
If the code in the contained file is already included, it is not included again. Require_once () is applicable when a file may be contained multiple times during script execution, so that it is included only once to avoid function redefinition and variable re-assignment.
3. Differences between Include and include _ once ()
If the code in the contained file is already included, it is not included again. Require_once () is applicable when a file may be contained multiple times during script execution, so that it is included only once to avoid function redefinition and variable re-assignment.
4. Difference Between Require_once () and include_once ()
It should be noted that the behavior of require_once () and include_once () in case of an error is completely different. include will generate a warning, and the subsequent code will continue to be executed, while require_once () this leads to a fatal error. Stop the script and continue running.
Applicability:
Contains any number of files. If an error occurs, use require () to stop the script ();
Contains any number of files. If an error occurs and does not stop, use include ();
If the script file is stopped when an error occurs, use require_once ();
Contains files once. If an error occurs and does not stop, use include_once ();