还有require
个和include_once
个.
所以你的问题应该是...
- 我什么时候应该使用
require
对include
?
- 我什么时候应该使用
require_once
对require
1的答案是here.
REQUIRED()函数与include()相同,只是它处理错误的方式不同.如果出现错误,include()函数将生成警告,但脚本将继续执行.REQUIRED()会生成致命错误,脚本将停止.
2的答案可以在here中找到.
REQUIRED_ONCE()语句与REQUIRED()相同,不同之处在于PHP将判断该文件是否已经包含,如果已经包含,则不再包含(要求)该文件.