我的代码是:
function errors($number,$string,$file,$line)
{
$error = $string.' In '.$file.', on line '.$line."'n";
error_log($error);
}
set_error_handler('errors',E_ALL);
下一行停止显示错误,因为我正在使用@
操作符。但是,我的问题是set_error_handler
在error.log
文件中写入错误。
echo @$undefined_variable; // I don't want to write this error in error.log file
虽然更好的解决方案是修复未定义变量问题,但您可以像这样做您所要求的:
ini_set('log_errors', false);
echo $undefined_variable;
ini_set('log_errors', true);
再次,我强烈建议您解决这个问题(要么定义变量,要么在使用它之前用isset检查它),而不是掩盖错误。