Power of base 0 and negative exponent is deprecated¶
Description¶
Requesting a negative exponent on 0 yields this error message. While PHP 8.3- used to generate INF as result, PHP 8.4 is moving toward generating a DivisionByZeroError: this will be set in PHP 9.0.
Example¶
<?php
$x = 0;
$y = $x ** -2;
?>
Solutions¶
Check for 0 before raising a negative power. Positive powers are OK.
Check for negative power before raising a power of 0.
Use the PHP 8.4 function fpow() that has the future behavior, with a try/catch structure.