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

Comparison between include() and require() in php

WBOY
WBOYOriginal
2016-08-08 09:33:571013browse

PHP's require() performance is similar to include(). The difference is that for include(), the file must be read and evaluated every time when include() is executed; while for require(), the file is only processed once (in fact, the file content replaces require () statement). This means that if you have code that contains one of these instructions and code that may be executed multiple times, it is more efficient to use require(). On the other hand, if you read a different file each time the code is executed, or have a loop that iterates through a set of files, use include() because you can set a variable for the name of the file you want to include. When the argument is Use this variable when including().

Original author: unknown
Source: MySQL Guide


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

Statement:
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