Require and include two ways to provide different use flexibility.
Require use methods such as require ("myrequirefile.php");. This function is usually placed at the front of the PHP program, and before the PHP program is executed, it is read into the file specified by require to make it a part of the PHP program's Web page. Commonly used functions, you can also use this method to introduce it into the Web page.
Include usage methods such as include ("myincludefile.php");. This function is generally placed in the processing section of the Process Control. The PHP Program page reads the include file when it is read. This way, you can simplify the process of executing the program.
1.incluce loading at time of use
2.require loads at the beginning
The 3._once suffix indicates that the load is not loaded
The PHP system has a pseudo-compile process when loading PHP programs, which can make the program run faster. But Incluce's documentation is still interpreted to perform
An error occurred in the include file and the main program continues to execute
The Require file went wrong and the main program stopped.
So the included file error has little impact on the system (such as interface files) with include, otherwise with require
The following documents also apply to require (). These two structures are exactly the same in addition to how they handle failures. 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. Also be sure to set the appropriate include_path.
The Require () function replaces itself with the contents of a given file, which occurs during the PHP engine's compile code, rather than during execution, and is not evaluated first, as in include (). The Require () function is used more in static elements, while the include () is more used in dynamic elements. Similar to Include_once (), require_once () will first check if the given code has been inserted, and if the code already exists, it will no longer be inserted.