For the difference between require, require_once, include and include_once, requireonceinclude
I. Definition
Require, require_once, include, and include_once all belong to PHP keywords. That is to say, they are actually PHP statements, rather than functions. Similar to print and echo, they are also PHP output statements, rather than functions. But in more cases, it is often called a function.
Ii. Usage
Require 'test. php ', require_once' test. php ', or require ('test. php '), require_once ('test. php. They are used to introduce another file in one file. Although they can contain parentheses, they are not functions. I prefer to use quotation marks.
Iii. Differences between require and require_once
When require () is referenced in the current file, multiple references or repetitions of classes or methods may occur. Require_once () receives an address as a parameter. When cited in the current file, it first checks whether the referenced or referenced class or method exists in the referenced file, make sure that the class or method has not been referenced.
Iv. Differences between include and include_once
Include works the same as require, include_once, and require_once.
5. Differences between include (include_once) and require (require_once)
When include and include_once reference a file, if an error occurs, a warning is issued, the Referenced File is stopped, and the current file continues to run. The overall code will not stop running.
When require and require_once reference a file, if an error occurs, a warning is immediately issued and the overall code is stopped. Therefore, require and require_once are more secure.
Vi. Advantages and Disadvantages
Require_once requires a longer running time, so the efficiency is relatively low. If time is preferred, require is a better choice, but in more cases, time and efficiency are a balance.
7. usefulness
Require And require_once are generally used to contain class files. Include and include_once are generally used to include template files.
(If there is any inaccuracy, please note)