.. _arrays-stringinitialization: .. _array-with-string-initialization: Array With String Initialization ++++++++++++++++++++++++++++++++ It used to be possible to initialize a variable with an string, and use it as an array. It is not the case anymore in PHP 7.1. .. code-block:: php See also `PHP 7.1 no longer converts string to arrays the first time a value is assigned with square bracket notation `_. Related PHP errors ------------------- + `Cannot use a scalar value as an array `_ Connex PHP features ------------------- + `initialisation `_ Suggestions ___________ * Always initialize arrays with an empty array(), not a string. Specs _____ +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Short name | Arrays/StringInitialization | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`CompatibilityPHP71 ` | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 1.6.5 | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Precision | High | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+-------------------------------------------------------------------------------------------------------------------------+