【发布时间】:2016-06-16 07:57:55
【问题描述】:
我有一个 PHP 系统,它没有在函数中使用 global $var; 定义变量的全局范围,并且可以在服务器上工作,但不能在我的本地系统上工作。
这是对 PHP 范围规则的更改,还是有允许这样做的设置?我的本地系统运行的是php 5.5.36,不知道服务器运行的是什么版本。
编辑:添加代码示例
这适用于服务器
include_once("common.inc.php"); // this defines $physical_path
class Admin extends AdminData
{
function Admin($admin_auth_id='') {
include_once($physical_path['DB_Access']. 'SubadminCommittee.php');
// many more lines of code follow
}
}
这适用于运行 5.5.36 的本地 PHP
include_once("common.inc.php"); // this defines $physical_path
class Admin extends AdminData
{
function Admin($admin_auth_id='') {
global $physical_path; // why is this line not needed on server?
include_once($physical_path['DB_Access']. 'SubadminCommittee.php');
// many more lines of code follow
}
}
【问题讨论】:
-
请提供代码示例。基于模糊的描述,我们无法对此发表任何评论。
-
@deceze 我添加了一个代码示例,不幸的是我无法在服务器上重现它,而且我没有地方可以创建一个简单的示例。这个系统不是我创建的。