• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

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

php 搞代码 3年前 (2022-01-23) 9次浏览 已收录 0个评论

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

PHP code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?phpfunction error($errorno,$errormes,$errorfile,$errorline){$error_info="错误信息:".$errorno."--".$errormes." in ".$errorfile." on line ".$errorline;echo $error_info;date_default_timezone_set("PRC");error_log("时间:".date("Y-m-d H:i:s")."-".$error_info."\r\n",3,"error_log.txt");die();}set_error_handler(error);$fp=fopen("aa.txt","r");if(!$fp){trigger_error("文件打不开");}else{echo"kai";}

运行后提示:
错误信息:2–fopen(aa.txt) [function.fopen]: failed to open stream: No such file or本文来源gaodai#ma#com搞*!代#%^码$网!搞代gaodaima码 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’);
是配合使用,一个抛出,一个接受,处理


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:使用trigger_error如何没有显示自定义的异常信息
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址