try{
$error = "哥,木有此目录呀"
if(is_dir("d:/wwwroot")){
echo "有此目录";
}else{
throw new Exception($error,__LINE__);
}
echo "Author:wxy545812093@126.com";
}catch (Exception $e){
echo "错误提示:".$e -> getMessage()."<br>";//获取自定义错误提示
echo $e ->getLine()."<br>";//获取错误行号
echo $e -> getFile()."<br>";//获取错误所在的文件 .
echo $e -> __toString()."<br>";//获取错误所有信息.
print_r($e -> getTrace()) ."<br>";//未知的array
echo $e -> getTraceAsString();//#0
}
【例】PHP 中try catch execption 的常用方法
最新推荐文章于 2021-03-09 18:37:26 发布