Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Cannot Raise Zero To Negative Powers

Raising 0 to a negative power used to generate a INF value, aka infinity. The standard behavior is to generate a DivisionByZeroError, as this is not mathematically allowed. This behavior is deprecated in PHP 8.4, and will be removed in PHP 8.4. During the transition, a function called fpow() is provided, with the new behavior.

PHP code

<?php

var_dump(0 ** -1); //Deprecated: Zero raised to a negative power is deprecated

?>

Before

float(INF)

After

PHP Deprecated:  Power of base 0 and negative exponent is deprecated

Deprecated: Power of base 0 and negative exponent is deprecated
float(INF)

PHP version change

This behavior was deprecated in 8.4.

This behavior changed in 9.0.

See Also

Error Messages

Extension

Analyzer

© 2023-2026, Damien Seguy - Exakat