try catch

来源:互联网 发布:数据分析师培训哪家好 编辑:程序博客网 时间:2024/05/16 08:08
try {if (file_exists('test_try_catch.php')) {require ('test_try_catch.php');} else {echo 'AA'."</br>";throw new Exception('file is not exists');//抛出异常'file is not exists'}} catch (Exception $e) {echo '11333';echo $e->getMessage();//如果异常--会接收上面抛出的异常,输出上面设定的'file is not exists'//异常后,会输出AA和11333//如果抛出了一个异常,try语句中的脚本将会停止执行,然后马上转向执行catch语句中的脚本。}

感谢:http://developer.51cto.com/art/200912/166409.htm

感谢:http://www.jb51.net/article/57688.htm

0 0
原创粉丝点击