The include () and require (): statements include and run the specified file.
The include () generates a warning and require () causes a fatal error. In other words, if you want to stop processing a page when you encounter a lost file, use require (). The include () is not the case and the script will continue to run.
The require_once () statement includes and runs the specified file during script execution. This behavior is similar to the Require () statement, except that if the code in the file is already included, it will not be included again.
The include_once () statement includes and runs the specified file during script execution. This behavior is similar to the include () statement, except that if the code in the file is already included, it will not be included again. As the name of this statement implies, it is included only once.
The 1.include () function reads the specified file into and executes the program inside it.
For example: include ('/home/me/myfile ');
The program code in the file being imported is executed, and these programs are executed with the same variable range (variable scope) as the source file where the call to the include () function is located. You can import static files from the same server, and you can even use the include () and fopen () functions to import files on other servers.
The role of the 2.include_once () function and the include () are almost identical
The only difference is that the include_once () function checks that the file to be imported is already imported elsewhere in the program, and if it does not re-import the file again (this feature is sometimes important, such as the file you want to import declares some functions that you define yourself , then if the file is repeatedly imported in the same program, an error message will occur at the second import, because PHP does not allow the same name function to be repeated for the second time.
The 3.require () function reads the contents of the target file and replaces itself with these read-in content.
This read-and-replace action occurs when the PHP engine compiles your program code, not when the PHP engine starts to execute the compiled program code (the PHP 3.0 engine works by compiling one line, but PHP 4.0 has changed, and PHP 4.0 is the first to put the entire After all the program code is compiled, the compiled program code is executed once, and no program code is executed during the compilation process. Require () is typically used to import static content, while the include () is suitable for importing dynamic program code.
4. Like the Include_once () function, the require_once () function will first check that the contents of the target file have been imported before and, if so, will not re-import the same content again.
http://www.bkjia.com/PHPjc/736849.html www.bkjia.com true http://www.bkjia.com/PHPjc/736849.html techarticle the include () and require (): statements include and run the specified file. The include () generates a warning and require () causes a fatal error. In other words, if you want to encounter lost files ...