Home > Backend Development > PHP Tutorial > Comparative analysis of include() and require() in php

Comparative analysis of include() and require() in php

WBOY
Release: 2016-07-25 09:05:48
Original
850 people have browsed it
There is no big difference in performance between PHP's require() and include(). The only differences are that when include() is executed, the file is read and evaluated each time; when require() is executed, the file is only processed once (in fact, the file content replaces the require() statement).

There is no big difference in performance between PHP's require() and include(). The only differences are: When include() is executed, the file must be read and evaluated every time; The file is processed only once when require() is executed (in fact, the file content replaces the require() statement). That is, 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().

In addition, if you need to read a different file each time the code is executed, or have a loop that iterates through a set of files, you should use include(), because you can set a variable for the file name you want to include. When the parameter is Use this variable when including().



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