Provides various official and user-released code examples and code reference. You are welcome to share the following learning files:
Include/include_once
Require/require_once
Both Include and require introduce a page to the current page.
How to Understand "Introduction ".
It is equivalent to replacing include/require with all the code of the contained file.
It is the same as writing the code in the include statement directly.
Require is used to introduce a file to the current file.
Similar to include.
Difference between Include and require
A: If the introduced file does not exist, include tries to continue and reports a warning
(If you don't mind whether or not the previous content is included and all subsequent content needs to be executed, use include)
If the file introduced by require does not exist, the system reports a fatal error and does not continue executing the request.
(If the previous content must be included before continuing to execute the code, use require)
========================================================== ======================
Difference between Include/require and include_once/require_once
_ Once automatically determines whether the file has been introduced. If yes, it will not be executed repeatedly.
That is, ensure that the contained file can be introduced only once.
(If the contained file contains a defined function, the contained file can only be contained once. If it is included multiple times, a function redefinition error will occur, php does not run function redefinition, and a fatal error may occur, and the code will not run later)
========================================================== ====================
Some files cannot be contained multiple times?
You can use _ once to control,
However, if the document design is more standardized, it is guaranteed that there will be no inclusion errors for multiple times,
In this case, we recommend that you use include
Because include_once needs to check whether it has been included before, the efficiency is not as high as include.
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB