事务就是遇到错误时终止运行,转到catch抛出异常
1 try { 2 if (file_exists('test_try_catch.php')) { 3 require ('test_try_catch.php'); 4 } else { 5 throw new Exception('file is not exists'); 6 } 7 } catch (Exception $e) { 8 echo $e->getMessage(); 9 }
posted on 2019-07-18 11:51 毛宏钢 阅读(133) 评论(0) 收藏 举报
博客园 © 2004-2025 浙公网安备 33010602011771号 浙ICP备2021040463号-3