Increment On Boolean Is Deprecated¶
Incrementing or decrementing a boolean value had no effect. In PHP 8.3, it is now a deprecation warning, and a message.
PHP code¶
<?php
$a = true;
$a++;
$b = false;
--$b;
echo $a, $b;
?>
Before¶
1
After¶
PHP Warning: Increment on type bool has no effect, this will change in the next major version of PHP in /codes/incrementOnBoolean.php on line 4
Warning: Increment on type bool has no effect, this will change in the next major version of PHP in /codes/incrementOnBoolean.php on line 4
PHP Warning: Decrement on type bool has no effect, this will change in the next major version of PHP in /codes/incrementOnBoolean.php on line 7
Warning: Decrement on type bool has no effect, this will change in the next major version of PHP in /codes/incrementOnBoolean.php on line 7
1
PHP version change¶
This behavior was deprecated in 8.3
This behavior changed in 9.0