Home > Backend Development > PHP Tutorial > Comparison between include() and require() in php

Comparison between include() and require() in php

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-08-08 09:34:13
Original
1109 people have browsed it

The performance of require() in php is similar to include(), and the usage method is basically the same.

The difference between them is that for include(), the file must be read and evaluated every time when include() is executed;

For require(), the code containing the file is only processed once.

This means that if there is code that contains one of these instructions and code that may be executed multiple times, it is more efficient to use require().

If you read a different file each time you execute the code, or if you have a loop that iterates through a set of files, use include(). You can read it every time because you can set a variable for the file name you want to include. , this variable is used when the parameter is include().



The above has introduced the comparison between include() and require() in PHP, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

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
Latest Issues
include error
From 1970-01-01 08:00:00
0
0
0
How to include a file in ubuntu?
From 1970-01-01 08:00:00
0
0
0
Why can't I load the content in include?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template