Home >Backend Development >PHP Tutorial >Comparative analysis of include() and require() in php
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(). |