Home > php教程 > php手册 > include,include_once,require,require_once的区别,requireonceinclude

include,include_once,require,require_once的区别,requireonceinclude

WBOY
Release: 2016-06-13 08:51:17
Original
1209 people have browsed it

include,include_once,require,require_once的区别,requireonceinclude

1、include,require在其被调用的位置处包含一个文件。

2、include_once,require_once函数的作用与include相同,不过它会首先验证是否已包含该文件。如果已经包含,则不再执行include_once。其他同include一样。

3、require与include最主要的区别,a、require出错时,脚本将停止运行,而include出错的情况下,脚本将继续执行。b、无论require的位置如何,制定文件都将包含到出现require的脚本中。例如,即使require放在计算结果为假的if语句中,依然会包含指定文件。

4、使用require_once可以解决文件被覆盖的问题。 require_once函数确保文件只包含一次。在遇到require_once后,后面再试图包含相同的文件时将被忽略。

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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template