<?
function checkNum($num){
if($num>1){
throw new Exception("异常提示-数字必须小于等于1");
}
return true;
}
try{
checkNum(2);
}catch(Exception $e){
$e->getMessage();
}
$filename='text.txt';
try{
if(!file_exists($filename)){
throw new Exception('文件不存在');
}
}catch(Exception $e){
echo $e->getMessage();
}