包含的脚本中的单独的调试变量

时间:2018-11-23 07:26:07

标签: php include dynamic-variables

除了我的最后一个问题,我还有一个新问题: 我想在每个脚本上使用相同的调试代码,但无法避免所包含的页面更改调试变量的值:请参见: php文件“ loadData.php”具有以下调试脚本:

$file=pathinfo(__FILE__)['filename'];
$debugValue=true;
$debug{$file}=$debugValue;

if($debug{$file}){
    echo "Achtung: Testausgabe von ".$file.".php ist an!</br>"; 
}

$ini_config = parse_ini_file("config.ini", true);
$DB=$ini_config['php']['database'];//Speicherung der Daten

//database einbinden
include($DB);

//FUNKTION getProjektID:


if($debug{$file}){
    $projektname='Testprojekt';
}else{
    $projektname=$_REQUEST['projektname'];
}

我在include($DB);中包含了database.php文件。

在database.php中,我具有以下调试代码:

$file=pathinfo(__FILE__)['filename'];
$debugValue=false;

$debug{$file}=$debugValue;

if($debug{$file}){
    echo "Achtung: Testausgabe von ".$file.".php ist an!</br>"; 
}

我现在的问题是,在插入数据库后,$debug{$file}-值更改为false。

我以我的变通办法在每个文件中创建一个动态变量,我可以避免调试变量被另一个脚本更改,但这似乎不起作用。

如何避免这种情况?

是否有一种方法可以在脚本中修复变量$debug{$file},以便在包含另一个脚本后不能对其进行更改?

感谢您的帮助。

0 个答案:

没有答案