当前位置:Gxlcms > PHP教程 > 使用trigger_error如何没有显示自定义的异常信息

使用trigger_error如何没有显示自定义的异常信息

时间:2021-07-01 10:21:17 帮助过:23人阅读

使用trigger_error怎么没有显示自定义的错误信息
PHP code


运行后提示:
错误信息:2--fopen(aa.txt) [function.fopen]: failed to open stream: No such file or directory in D:\AppServ\www\test.php on line 10
为什么错误信息“fopen(aa.txt) [function.fopen]: failed to open stream: No such file or directory ”不是我用trigger_error定义的“文件打不开”,应该怎么改

------解决方案--------------------
set_error_handler(error);
===>
set_error_handler("error");
------解决方案--------------------
确认文件及路径正确了? 当前目录下有aa.txt文件吗?
------解决方案--------------------
trigger_error("不能存在", E_USER_ERROR);

通常
trigger_error()
set_error_handler('error_handler');
是配合使用,一个抛出,一个接受,处理

人气教程排行