gpt4 book ai didi

php - 如何判断文件是否已被要求?

转载 作者:可可西里 更新时间:2023-11-01 13:32:33 25 4
gpt4 key购买 nike

我已经创建了一个 php 全局文件 (globs.php),并且在我的所有页面中都需要它。但是,有些页面现在包含其他页面,当它再次尝试要求 globs.php 时出现错误。

如何判断文件是否已被要求?这样,我可以做 if !required('globs.php') require('globs.php')。

最佳答案

使用require_once相反:

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...

关于php - 如何判断文件是否已被要求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6823424/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com