Home >Backend Development >PHP Tutorial >php include,include_once,require,require_once_PHP教程
include_once and require_once have similar functions, that is, when including, check whether the included file has been included. If it has been included, it will not be executed, otherwise it will be included again. The reason why I say this first is because if include and require are Clear. Then this is no problem.
Now let’s talk about the difference between include and require:
The content included in the require() function is regarded as an integral part of the current file, so when included When the file has syntax errors or the file does not exist, the PHP script of the current file will no longer be executed. The
include() function is equivalent to specifying the path of the file. When the included file has errors, it will not affect itself. The program runs.
The include function can determine whether it is included, while require is included regardless of the situation. So this is worth noting!
It is recommended that you include dynamic files, that is, variables, functions, etc. Use include for classes. However, some time ago someone was analyzing the execution efficiency of the two functions. I have not tested this myself. I will add more after testing it myself