String Increments¶
String increments are the ++ operator applied to a string. The last character is updated to the next one in ASCII order, with a wrap up after z. This feature was deprecated in PHP 8.3, and the str_increment() and str_decrement() functions are introduced to replace it.
PHP code¶
<?php
$a = 'abc';
// $a = 'ab!';
// in PHP 8.4, the last char must be non-alpha numeric to emit the warning
$a++;
echo $a;
?>
Before¶
abd
After¶
PHP Deprecated: Increment on non-alphanumeric string is deprecated
abds
PHP version change¶
This behavior changed in 5.6