About the difference between Require,require_once,include and include_once, Requireonceinclude
First, the definition
Require,require_once,include,include_once are all PHP keywords, which means that they are actually PHP statements, not functions, like Print,echo, but also the output statements of PHP, not functions. But more often than not, people are called functions.
Second, usage
Require ' test.php ', require_once ' test.php ', or require (' test.php '), require_once (' test.php ') are all possible, as is the case for include. They are used when you need to introduce another file in one file. Although they can be parentheses, but not functions, I prefer to use quotation marks.
Iii. the difference between require and require_once
When require () is referenced in the current file, multiple references or duplicates of the class or method may occur. When require_once () receives an address as a parameter and is referenced in the current file, it first checks whether the class or method in the referenced file has been referenced or has occurred, ensuring that the class or method is not referenced.
Iv. the difference between include and include_once
Include has the same effect as require,include_once and require_once.
Five, the difference between include (include_once) and require (require_once)
Include and include_once when referencing a file, if an error occurs, a warning is issued, and the referenced file is stopped running, and then the current file continues to run, and the overall code runs without stopping.
Require and require_once when referencing a file, if an error occurs, a warning is issued immediately and then the overall code is stopped. So require and require_once want to be safer.
Vi. Advantages and Disadvantages
Require_once need to run longer, so the efficiency is relatively low. Require is a better choice if time takes precedence, but time and efficiency are a balance in more times.
Seven, use
Require and require_once are generally used to include class files. Include and include_once are typically used to include template files.
(There are not exact places, please point out)
http://www.bkjia.com/PHPjc/1051220.html www.bkjia.com true http://www.bkjia.com/PHPjc/1051220.html techarticle on the difference between Require,require_once,include and include_once, Requireonceinclude one, define Require,require_once,include,include_ Once are the keywords of PHP, which means they are real ...