Use a try...catch statement to handle exceptions:
<?php
try {
throw new Exception("This is an exception");
} catch(Exception $e) {
echo $e->getMessage();
}
?>
Try it Yourself »
The try
keyword is used to create a try...catch
, or a try...catch...finally
statement.
The throw
keyword.
The catch
keyword.
The finally
keyword.
Read more about try..catch.finally (Exceptions) in our PHP Exceptions Tutorial.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!