主页
PHP
PHP 异常
tryphp_exceptions_obj_info
运行 ❯
×
更改方向
保存代码
更改主题
<!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); } catch(Exception $e) { $code = $e->getCode(); $message = $e->getMessage(); $file = $e->getFile(); $line = $e->getLine(); echo "Exception thrown in $file on line $line: [Code $code] $message"; } ?> </body> </html>
第 8 行的 /home/TwT0ln/prog.php 文件中出现异常:[代码 1] 除以零