.. _increment-on-non-numeric-string-is-deprecated,-use-str_increment()-instead:
Increment on non-numeric string is deprecated, use str_increment() instead
--------------------------------------------------------------------------
.. meta::
:description:
Increment on non-numeric string is deprecated, use str_increment() instead: PHP 8.
:og:image: https://php-errors.readthedocs.io/en/latest/_static/logo.png
:og:type: article
:og:title: Increment on non-numeric string is deprecated, use str_increment() instead
:og:description: PHP 8
:og:url: https://php-errors.readthedocs.io/en/latest/messages/increment-on-non-numeric-string-is-deprecated%2C-use-str_increment%28%29-instead.html
:og:locale: en
:twitter:card: summary_large_image
:twitter:site: @exakat
:twitter:title: Increment on non-numeric string is deprecated, use str_increment() instead
:twitter:description: Increment on non-numeric string is deprecated, use str_increment() instead: PHP 8
:twitter:creator: @exakat
:twitter:image:src: https://php-errors.readthedocs.io/en/latest/_static/logo.png
.. raw:: html
Description
___________
PHP 8.3 introduced str_increment() and str_decrement(), which update strings by changing the last character's ascii code. It mirrors a famous PHP easter egg, where a string may be incremented with the ``++`` operator.
In PHP 8.5, this feature is deprecated, and a warning is emitted. There is no deprecation warning for decrementing, as the feature was not implemented on strings.
Example
_______
.. code-block:: php
Solutions
_________
+ Use str_increment(), instead of ``++`` on string variables.
Changed Behavior
________________
This error may appear following an evolution in behavior, in previous versions. See `incrementNonAlphanumeric `_.
Static Analysis
_______________
This error may be tracked down with the following static analysis rules: `Php/PlusPlusOnLetters `_.