1. The include () include (/path/to/filename) include () statement will include a file at the called location. A file contains the same content as the data copied to the file where the statement is located. Parentheses can be ignored when include () is used. You can execute the include () statement according to the conditions. The use of include () in conditional statements has a strange phenomenon. It must be enclosed in statement block braces or enclosed by other statements.
2. The include_once () include_once (filename) include_once () function has the same role as include, but it will first verify whether the file is included. If it already exists, revoke de_once is not executed. Otherwise, the file must be included. This is the same as include.
3. Require () require (filename) require () is similar to include to a large extent. A template file is included in the location where the require call is located. There are two important differences between require and include. First, regardless of the location of require, the file will be included in the script where require appears. For example, even if require is placed in an if statement whose calculation result is false, it still contains the specified file. The second important difference is that when a require error occurs, the script stops running, and the script continues to run when the include is used.
4. As the website grows, require_once () require_once (filename) may duplicate some files. This may not be a problem, but after modifying the variable of the included file, it is overwritten because it contains the original file again. This may not happen. Another problem may also occur, that is, the conflict of letters in the file. Use require_once to solve these problems. The require_once function ensures that the file is only contained once. If you encounter require_once and try to include the same file later, it will be ignored.
Differences:
The difference between include () and require:
They all load the specified script and run the loaded script.
Differences:
Inlucde () will continue to be executed if loading fails,
Require () if the file to be loaded does not exist, an error will be reported and it is straight.
Difference between include_once () and require_once:
They are all loading and running the following script
Differences:
Include_once, even if the imported file is not stored belowCodeWill continue. If the file imported by require_once does not exist,ProgramIt will end. In general, it does not affect the HTML file of the program, such as using include_once to import the library file configuration file, and so on to use require_once for import.