Bug #15533 Updated: Indexing a string variable with a text key returns 1st element of string

From: Date: Wed, 13 Feb 2002 10:44:42 +0000
Subject: Bug #15533 Updated: Indexing a string variable with a text key returns 1st element of string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230@lists.php.net to get a copy of this message
ID: 15533 Updated by: hholzgra@php.net Reported By: fred@observe.co.za -Status: Open +Status: Bogus Bug Type: Variables related Operating System: Linux PHP Version: 4.0.6 New Comment: $string[...] and $string{...} both allow single character access to strings. the {} variant is recommended for PHP 4, but the older version using [] still works the indices inside [...] or {...} are interpreted as integers, strings are casted to integers, and (int)'blah' is zero, that's it Previous Comments: ------------------------------------------------------------------------ [2002-02-13 03:08:52] fred@observe.co.za <? $arg = '123'; // prints 123 echo "arg = $arg<br>\n"; // prints nothing echo "is_array(arg) = ", is_array($arg), "<br>\n"; // prints 1 echo "arg[blah] = $arg[blah]<br>\n"; ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=15533&edit=1

« previous php.bugs (#230) next »