主页
PHP
PHP catch 关键字
tryphp_keyword_catch2
运行 ❯
×
更改方向
保存代码
更改主题
<?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"; } ?>