时间:2021-07-01 10:21:17 帮助过:33人阅读
输出了错误信息:Warning: Division by zero in......
- <br><meta http-equiv="content-type" content="text/html;charset=utf-8" /><?php <br>set_exception_handler("My_expection"); <br>function My_expection(){ <br>echo "这里是顶级异常处理器"; <br>} <br>try{ <br>nohello("hello"); <br>}catch(Exception $e){ <br>throw $e; <br>} <br> function nohello($nohello){ <br> if($nohello == "hello"){ <br> throw new Exception("不能输入hello"); <br> }else{ <br>echo "输入成功"; <br>} <br>} <br>?> <br> <br>关于PHP异常处理 的一个问题 <br><span><u></u></span> 代码如下:<pre class="brush:php;toolbar:false layui-box layui-code-view layui-code-notepad"><ol class="layui-code-ol"><li><br><?php <br>try { <br>$a=10/0; <br>}catch (Exception $e){ <br>echo "抛出异常"; <br>} <br>?> <br> <br>以上代码,并不会</li></ol></pre>输出“抛出异常”,而是