There are require
and include_once
as well.
(还有require
和include_once
。)
So your question should be...
(所以你的问题应该是...)
- When should I use
require
vs. include
? (什么时候应该使用require
与include
?)
- When should I use
require_once
vs. require
(我何时应该使用require_once
与require
)
The answer to 1 is described here .
(这里描述1的答案。)
The require() function is identical to include(), except that it handles errors differently.
(require()函数与include()相同,除了它对错误的处理方式不同。)
If an error occurs, the include() function generates a warning, but the script will continue execution. (如果发生错误,include()函数将生成警告,但脚本将继续执行。)
The require() generates a fatal error, and the script will stop. (require()产生致命错误,脚本将停止。)
The answer to 2 can be found here .
(在这里可以找到2的答案。)
The require_once() statement is identical to require() except PHP will check if the file has already been included, and if so, not include (require) it again.
(require_once()语句与require()相同,除了PHP会检查文件是否已包含,如果不包含,则不要再次包含(require)该文件。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…