round() Mode Validation¶
round() function has four modes, defined with 4 constants. When the 3rd argument is not one of those four constants, PHP used to silently use PHP_ROUND_HALF_UP as default value. In PHP 8.4, a ValueError is provided.
PHP code¶
<?php
print $a = round(1.2, 2, 333);
?>
Before¶
1
After¶
round(): Argument #3 ($mode) must be a valid rounding mode (PHP_ROUND_*)
PHP version change¶
This behavior changed in 8.4