PHP中try{}和catch{}的具体用法详细解释

xiaoxiao2021-02-28  69

PHP中try{}catch{}是异常处理,将要执行的代码放入TRY块中,如果这些代码执行过程中某一条语句发生异常,则程序直接跳转到CATCH块中,由$e收集错误信息和显示。任何调用 可能抛出异常的方法的代码都应该使用try语句,Catch语句用来处理可能抛出的异常。

try { $TemplatesObj = new Templates(); $this->mx_success($TemplatesObj->getTemplateInfo($affairs_template_id)); } catch (Exception $e) { $this->mx_error($e->getMessage()); }

转载请注明原文地址: https://www.6miu.com/read-50585.html

最新回复(0)