Home > Backend Development > PHP Tutorial > php include,include_once,require,require_once_PHP教程

php include,include_once,require,require_once_PHP教程

WBOY
Release: 2016-07-21 15:50:09
Original
914 people have browsed it

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319423.htmlTechArticleinclude_once and require_once have similar functions. They are to check whether the included file has been included when included. If If it has been included, then it will not be executed, otherwise it will be included again. Let me say this first...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template