标签:抛出异常 function php exception get catch sage cti his
<?php
function checknum($num)
{
if($num >= 2)
{
throw new Exception("must below 2"); //抛出异常
}
echo "ll <br>";
return true;
}
try //触发异常
{
checknum(2);
echo "if you see this ,the num is true";
}
catch(Exception $e) //捕获异常,并创建一个含异常信息的对象
{
echo "message :".$e->getMessage();
}
?>
标签:抛出异常 function php exception get catch sage cti his
原文地址:http://www.cnblogs.com/jiangger/p/6439832.html