【发布时间】:2013-03-28 12:03:09
【问题描述】:
我很难理解范围以及阻止我的新代码工作的原因(假设这是范围问题)。
以下函数位于引用类的文件PATH.'/includes/custom-functions.php' 中:
function infusion() {
require_once(PATH.'/classes/infusion.php'); //PATH is defined in WordPress from ~/wp-content/themes/theme/
return new infusion();
}
该类依赖于PATH.'/api/isdk.php' 和来自/api/ 目录中另一个文件的连接凭据。在PATH .'/includes/custom-functions.php' 中,我还有许多其他函数可以调用$infusion = infusion(); 并且可以完美运行。
问题
我创建了一个新文件:PATH.'/includes/report.php',我需要访问它$infusion = infusion();,但无法通过重复上面的function infusion() 定义来开始工作;使用require_once();;或使用include();。所有这 3 个选项只会杀死其余的代码,我只能得出结论 - 好吧,我没有结论。
任何帮助将不胜感激。
【问题讨论】:
标签: php api class function scope