我想打印"解析错误","致命错误","警告"而不是$exception->getCode()
,我该怎么做?
function exception_handler( $exception )
{
/*
* Parse error: syntax error, unexpected 'w' (T_STRING), expecting ';' or '{' in C:\xampp\htdocs\dermaquality\aplicacion\vista\paginas\Dermaquality\proceso\indicadores.php on line 25
*/
//echo $exception->__toString();
echo "<strong>" . $exception->getCode() . ": " . $exception->getMessage() . " in " . $exception->getFile() . " on line " . $exception->getLine() . "</strong><br/>\n";
echo str_replace( '#', '<br/>#', $exception->getTraceAsString() );
}
set_exception_handler('exception_handler');
答案 0 :(得分:0)
您可以尝试返回上一个错误的函数error_get_last。
<?php
echo $a;
print_r(error_get_last());
?>
那将打印
Array
(
[type] => 8
[message] => Undefined variable: a
[file] => C:\WWW\index.php
[line] => 2
)