我的配置文件config.php 里面有些参数定义我所有的代码必须在一个类里面执行(是插件,没办法)
比如:
class test{
function test(){
$a = new mytest();
}
}class mytest{
function mytest(){
require_once('config.php');
global $config;//我的代码很多都已经写成了global。这时候这里就真不管用了,因为config.php不在类外面。
}
}请问,我现在又想通过global的方式获取配置变量,如何做?
比如:
class test{
function test(){
$a = new mytest();
}
}class mytest{
function mytest(){
require_once('config.php');
global $config;//我的代码很多都已经写成了global。这时候这里就真不管用了,因为config.php不在类外面。
}
}请问,我现在又想通过global的方式获取配置变量,如何做?
没办法,是之前的写法。之前有些函数是这样的
function test(){
global $config;
}
这个写法是既成的,之前的写法。
好在我今晚已经把代码全部重构了。用$_ENV把变量加进去。通通不用global了,不管他在类里还是函数里面