Several GMP Functions Validate Their Numeric Arguments
gmp_fact() accepts a GMP object as its $num argument. Until PHP 8.6, a value outside the range of an unsigned long was silently misinterpreted, so gmp_fact() returned an unrelated, incorrect result instead of failing. In PHP 8.6, such a value throws a ValueError. The same release also refines the ValueError messages already thrown by gmp_pow(), gmp_binomial(), gmp_root() and gmp_rootrem() for an out-of-range second argument ($exponent, $k or $nth), now stating the full valid range instead of only the lower bound.
PHP code
<?php
$huge = gmp_init('18446744073709551616');
try {
var_dump(gmp_strval(gmp_fact($huge)));
} catch (\ValueError $e) {
echo "ValueError: ".$e->getMessage()."\n";
}
?>
Before
string(1) "1"
After
ValueError: gmp_fact(): Argument #1 ($num) must be between 0 and 18446744073709551615
PHP version change
This behavior changed in 8.6.