function myErrorHandler($errno, $errstr, $errfile, $errline)
{
switch ($errno) {
case E_USER_WARNING:
$errno = "USER_WARNING";
break;
case E_USER_NOTICE:
$errno = "USER_NOTICE";
break;
case E_NOTICE:
$errno = "NOTICE";
break;
case E_WARNING:
$errno = "WARNING";
break;
case E_RECOVERABLE_ERROR:
$errno = "RECOVERABLE_ERROR";
break;
case E_ALL:
$errno = "ALL";
break;
default:
$errno = "Unknown Error Type";
break;
}
return true;
}
set_error_handler("myErrorHandler");
我要怎麼把 errno errstr errfile errline取出來function外面用啊?
1 回答
一只斗牛犬
TA贡献1784条经验 获得超2个赞
可以结合try...catch...去使用
$trace = (new \Exception())->getTrace()[0];
echo '<br>文件号:'.$trace['file'].':'.$trace['line'];
- 1 回答
- 0 关注
- 369 浏览
添加回答
举报
0/150
提交
取消