PHP try catch 如何使用

 

<?php

 

try {

if (file_exists('test_try_catch.php')) {

require ('test_try_catch.php');

} else {

throw new Exception('file is not exists');

}

} catch (Exception $e) {

echo $e->getMessage();

}

 

 

 

具体使用场景:

 

 

文章来源:外星人来地球

欢迎关注,有问题一起学习欢迎留言、评论

posted @ 2019-09-11 12:11  刘俊涛的博客  阅读(2181)  评论(0编辑  收藏  举报