多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 通过Error类抛出错误 XPHP内置了错误处理引擎`Error`类,它不仅于内置的日志系统完美融合,而且符合用户习惯,错误界面美观,功能全面,模板可以自定义。 ## 抛出一个错误 首先,引入错误处理引擎: ```php use X\Error; ``` 然后,在需要抛出错误的时候,执行: ```php Error::Show("错误编号","错误信息","跳转地址(留空即为首页)","跳转时间(留空即为3)"); ``` ## 自定义错误模板 错误模板是 `System/Error` 。 您可以自行修改。 默认的模板: ```handlebars <html> <head> <title>XPHP {{$L['System']['Error']}}</title> <style> body{ margin:0; padding:30px; font:12px/1.5 "Microsoft Yahei UI",Helvetica,Arial,Verdana,sans-serif; } h1{ margin:0; font-size:48px; font-weight:normal; line-height:48px; } strong{ display:inline-block; width:65px; } </style> </head> <body> <h1>{{$L['System']['Error']}} {{$no ? "#".$no : ""}} :</h1> <h3> {{$e}} </h3> <p>{{$L['System']['WeHadRecordThisError']}}</p> {{# if ($jump){ }} <a href='{{$jump}}'>{{$L['System']['jumpNow']}}</a> ({{$sec}}{{$L['System']['SecondsAfterAutoJump']}}) <script type="text/javascript"> window.setTimeout("window.location.href='{{$jump}}';",{{$sec}}*1000); </script> {{# }else{ }} <a href='/'>{{$L['System']['BackHome']}}</a> {{# } }} </body> </html> ```