Home  >  Article  >  php教程  >  include()与require()的对比

include()与require()的对比

WBOY
WBOYOriginal
2016-06-13 10:37:56682browse

php的require()性能与include()相类似。不同之处在于,对include()来说,在include()执行时文件每次都要进行读取和评估;而对于require()来说,文件只处理一次(实际上,文件内容替换了require()语句)。这就意味着如果有包含这些指令之一的代码和可能执行多次的代码,则使用require()效率比较高。另一方面,如果每次执行代码时相读取不同的文件,或者有通过一组文件叠代的循环,就使用include(),因为可以给想要包括的文件名设置一个变量,当参数为include()时使用这个变量。

原作者:不详  
来源:mysql指南   


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