检查是否包含或加载文件 [英] Check if a file was included or loaded
本文介绍了检查是否包含或加载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有任何优雅的方法通过使用include
/include_once
/require
/require_once
来检查是否包含文件,或者页面是否实际上是直接加载的?创建类时,我正在尝试在类文件中设置测试文件.
Is there any elegant way to check if a file was included by using include
/include_once
/require
/require_once
or if the page was actually loaded directly? I'm trying to set up a testing file inside class files while I'm creating them.
我正在寻找类似于Python的if __name__ == "__main__":
技术的东西.无需设置全局变量或常量.
I'm looking for something similar to Python's if __name__ == "__main__":
technique. Without setting globals or constants.
推荐答案
查看全文