Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 智能错误抑制_Php_Templates_Smarty - Fatal编程技术网

Php 智能错误抑制

Php 智能错误抑制,php,templates,smarty,Php,Templates,Smarty,我试图在不使用error_reportingNULL的情况下执行错误抑制,同时向可能尚未设置的变量添加值。例如: {$var.1 = $var.1 + 10} 在本例中,$var.1尚未定义,在PHP中,我可以使用@infront of the line忽略错误。如何在Smarty上执行此操作?如果可以将代码提取到PHP,可以通过以下方式执行: $errorReportingLevel = $smarty->error_reporting; $smarty->error_repor

我试图在不使用error_reportingNULL的情况下执行错误抑制,同时向可能尚未设置的变量添加值。例如:

{$var.1 = $var.1 + 10}

在本例中,$var.1尚未定义,在PHP中,我可以使用@infront of the line忽略错误。如何在Smarty上执行此操作?

如果可以将代码提取到PHP,可以通过以下方式执行:

$errorReportingLevel = $smarty->error_reporting;
$smarty->error_reporting = 0;
echo $smarty->fetch('index.tpl');
$smarty->error_reporting = $errorReportingLevel;
echo $smarty->fetch('index.tpl');
在第一次通话中,你不会收到任何警告,而在第二次通话中,你会收到任何警告


据我所知,没有别的办法。此外,你应该考虑删除这个警告。代码的编写方式应该是不显示通知或警告-在PHP和Smarty中都可以。

可能重复的“我不想使用错误报告”\u这不是重复的,我不想忽略模板上的所有错误,我只想忽略显式错误。