/**************************************************** * php处理异常 * try中不主动throw,会先出现PHP的系统错误 ****************************************************/header("content-type:test/html:charset=utf-8");error_reporting(-1);try { $num1 = 3; $num2 = 0; if ($num2 == 0) { throw new Exception("自定义错误"); } else { $res = $num1 / $num2; }} catch (Exception $e) { echo $e->getMessage(); // die(); // 终止异常}