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
Warning: Increment on type bool has no effect, this will change in the next major version of PHP
PHP Warning: Decrement on type bool has no effect, this will change in the next major version of PHP
Warning: Decrement on type bool has no effect, this will change in the next major version of PHP
1
PHP version change
This behavior was deprecated in 8.3.
This behavior changed in 9.0.