note 95184 deleted from language.types.string by cmb

From: Date: Sun, 04 Aug 2019 09:10:41 +0000
Subject: note 95184 deleted from language.types.string by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211797@lists.php.net to get a copy of this message
Note Submitter: &#34;Sascha Ziemann&#34; ---- Empty strings seem to be no real strings, because they behave different to strings containing data. Here is an example. It is possible to change a character at a specific position using the square bracket notation: <?php $str = '0'; $str[0] = 'a'; echo $str."\n"; // => 'a' ?> It is also possible to change a character with does not exist, if the index is "behind" the end of the string: <?php $str = '0'; $str[1] = 'a'; echo $str."\n"; // => 0a ?> But if you do that on an empty string, the string gets silently converted into an array: <?php $str = ''; $str[0] = 'a'; echo $str."\n"; // => Array ?>

« previous php.notes (#211797) next »