Manual contradiction concerning string access?
| From: | Christian Heinrich | Date: | Tue, 20 Feb 2007 16:15:33 +0000 |
| Subject: | Manual contradiction concerning string access? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-249088@lists.php.net to get a copy of this message | ||
Dear list,
today, I read in a german PHP forum about a problem with accessing an offset of a string.
For example, if you have a variable like
$string = "this is my string";
and you want to access the third character at once, I would suggest to use
$string{2}
so this will return the "i".
The (german!) manual says about that: (http://de.php.net/manual/de/language.types.string.php#language.types.string.substr)
*Anmerkung: * Für Abwärtskompatibilität können Sie für den selben Zweck immer noch die Array-Klammern verwenden. Diese Syntax wird jedoch seit PHP 4 missbilligt.(Translation:)
*Note: *For downwards compatibility you may use the array brackets as well. But as of PHP 4, this syntax is deprecated.The english manual says: (Link: http://de.php.net/manual/en/language.types.string.php#language.types.string.substr )
*Note: * They may also be accessed using braces like $str{42} for the same purpose. However, using square array-brackets is preferred because the {braces} style is deprecated as of PHP 6.I'm a little bit confused by now. Which style should I pick? I use PHP 4 and 5. Is there any other difference? It would be great if someone could solve that contradiction within the manual, too. Thanks in advance. Sincere regards Christian Heinrich