运行 ❯
获取你的
专属 PHP
服务器
×
更改方向
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <?php try { $rand = rand(0, 2); switch($rand) { case 0: throw new Exception(); case 1: throw new OutOfBoundsException(); case 2: throw new LogicException(); } } catch(OutOfBoundsException $e) { echo "Caught an out of bounds exception"; } catch(LogicException $e) { echo "Caught a logic exception"; } catch(Exception $e) { echo "Caught an ordinary exception"; } ?> </body> </html>
捕获到一个越界异常