Home > Backend Development > PHP Tutorial > A brief description of the four functions of php include,include_once,require,require_once

A brief description of the four functions of php include,include_once,require,require_once

怪我咯
Release: 2023-03-12 20:26:02
Original
1549 people have browsed it

In factMany people still don’t fully understand these four functions of PHP file. Although they are often used, I will show you how to use them in certain places. Which one should be used? The functions of .

include_once and require_once are similar, that is, when including, it checks whether the included file has been included. If it has been included, it will not Execute, otherwise include again. The reason I say this first is because if the include and require are clear, then there will be no problem.
Now let’s talk about the difference between include and require:

require( ) function is regarded as an integral part of the current file, so when the included file has a syntax error 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 this file. When the included file is wrong, it will not affect the running of the program itself.
The include function can determine whether it is included, while require is included regardless of the situation. Come in. So this is worth noting!
It is recommended that you use include when including dynamic files, that is, variables, functions, and classes. However, some time ago someone was analyzing the execution efficiency of the two functions. I have not tested this myself. Passed, I will add more after testing it myself


The above is the detailed content of A brief description of the four functions of php include,include_once,require,require_once. For more information, please follow other related articles on the PHP Chinese website!

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