try(........){throw new Exception("xxxxxx")}........catch(){.........}用法
程序员文章站
2022-07-15 12:54:42
...
<?php
function ActionSend($mobile, $key='')
{
try
{
/* if (empty($key)) {
throw new Exception('key值不能为空');
}
if($key != 'adfasdfdasfs') {
throw new Exception('key值不一致');
}
echo 'oo';
*/
echo 1/0;
echo "throw";
//throw new Exception ( "Method not exists!" );
}
catch(Exception $e)
{
print_r($e);
echo "xxx";
}
}
ActionSend('15801668635','adfasdfdasfs');
?>
输出:
Warning: Division by zero in E:\wamp\www\test\try.php on line 16
throw