代码速记 / 3 / 2 / 创建于 2年前
function t($fun) { $output = [null, null]; try { $output[0] = $fun(); } catch (Exception $e) { $output[1] = $e; } return $output; }
[$output, $error] = t(function() { // 测试抛出错误 throw new Exception('error'); }); if ($error) { echo $error->getMessage(); }
有时候可以用到这样的
错误处理的核心在于处理,这多少有点放屁脱裤子了 :joy:
处理
我要举报该,理由是:
推荐文章: