// 报错, 扑捉不到异常 // try { // require ('test_try_catch.php'); // } catch (Exception $e) { // echo $e->getMessage(); // } // 能够扑捉到异常 try { if (file_exists('test_try_catch.php')) { require ('test_try_catch.php'); echo 23324444444444444; //不执行 } else { throw new Exception('文件不存在'); } } catch (Exception $e) { echo $e->getMessage(); } echo 232; //执行 php的try catch 能捕捉到的只能是你本身 throw new Exception("");的错误,throw以后的语句会进入到catch中继续执行。