I used to think about this issue when I was writing a program. Today I just saw this issue, so I will sort it out and summarize it!
These two structures are identical except for how to handle failures. Include () generates a warning and require ()
There are two methods to reference files: require and include. The two methods provide different elasticity. The use of require is as follows:
require("MyRequireFile.php");. This function is usually placed at the beginning of the PHP program. before
PHP's require () and include () are not very different in terms of performance. The only difference is that the file is read and evaluated every time the include () executes, and require () executes the file only once (in fact, the file contents
1. Include has a return value, and require does not. 2. Include () includes and runs the specified file when processing fails the include () generates a warning that the imported program code will be executed1. Include has a return value, and
How to use require as
require("MyRequireFile.php");。 This function is usually placed at the front of the PHP program, and before the PHP program executes, it is read into the file specified by require to make it a part of the PHP program's Web page.
Require and include two ways to provide different use flexibility.
Require use methods such as require ("myrequirefile.php");. This function is usually placed at the front of the PHP program, and before the PHP program is executed, it is read into
There are two methods to reference files: require and include. The two methods provide different elasticity.
RequireFor example
require("MyRequireFile.php");. This function is usually placed at the beginning of the PHP program. before the PHP
PHP's require () performance is similar to include (). The difference is that, for the include (), the file is read and evaluated every time the include () is executed, and for require (), the file is processed only once (in fact, the file contents
Require and include differ only when the file does not exist the way the error is not the same, the former stop the script, the latter continue to execute. is to introduce a file that introduces subsequent execution of the introduced file, and
Php's require () and include () have no major differences in performance between php's require () and include (), but have no major differences in performance.
The only difference is:
When executing include (), the file must be read and evaluated
PHP's require () and include () are not significantly different in terms of performance.
The only difference is:
When executing include (), the file must be read and evaluated each time;When require () is executed, the file is processed only
Php's require () performance is similar to include. The difference is that for include (), the file is read and evaluated each time when the include () is executed; For require (), the file is processed only once (in fact, the file content is
All 4 have the meaning of the containing file, but the include () and include_once () will continue to execute when there is an error in the include file, while require () and require_once () will not, in addition include_once () and Require_ Once ()
requireThe use of methods such as
require("MyRequireFile.php");。 This function is usually placed at the front of the PHP program, and before the PHP program executes, it is read into the file specified by require to make it a part of the PHP program'
There are two ways to refer to a file: Require and include. Two ways to provide different use elasticity.
Require use methods such as require ("myrequirefile.php");. This function is usually placed at the front of the PHP program, and before the
Php's require () and include () are not significantly different in terms of performance.The only difference is:When executing include (), the file must be read and evaluated each time;When require () is executed, the file is processed only once (in
First of all, let's say require, we know that if the file it introduces does not exist, it will cause the program to fail to continue, so it is usually at the very front of the program, often a particularly important part, such as connecting to a
If you've done Web sites of all sizes, it's important to be aware of the importance of reusing code snippets, whether it's HTML or PHP code blocks. For example, it takes a year to modify a footer that contains copyright information, and you have 1000
Server-side include (small industry) used to create features, headers, footers, or content that will be reused for multiple pages.Server-side IncludeYou can insert the contents of the file into the PHP file before the server executes it, with the
PHP Include Files
The server side includesYou can insert the contents of the file into the PHP file before the server executes it, with the include () or request () function. These two functions are the same in various ways, but how they handle
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.