php 8 之 ValueError
参考博客:https://www.php.cn/toutiao-462471.html
直接上代码:
<?php
try {
array_rand([], 0);
}catch (\ValueError $e){
print "ValueError:".PHP_EOL;
print_r($e);
}catch (\Exception $e){
print "Exception:".PHP_EOL;
print_r($e);
}catch (\Throwable $e){
print "Throwable:".PHP_EOL;
print_r($e);
}
在php 7的环境运行时:
在php 8的环境运行时: