主页
PHP
PHP 异常
tryphp_exceptions_finally
运行 ❯
×
更改方向
保存代码
更改主题
<!DOCTYPE html> <html> <body> <?php function divide($x, $y) { if($y == 0) { throw new Exception("Cannot divide by zero."); } return $x / $y; } try { echo divide(5, 0); // can throw an exception } catch(Exception $e) { echo 'Error: ' . $e->getMessage(); } finally { echo '<br>Process complete.'; } ?> </body> </html>
无法分割。处理完成。