|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15533 Indexing a string variable with a text key returns 1st element of string
Submitted: 2002-02-13 03:08 UTC Modified: 2002-02-13 05:44 UTC
From: fred at observe dot co dot za Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.0.6 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: fred at observe dot co dot za
New email:
PHP Version: OS:


 [2002-02-13 03:08 UTC] fred at observe dot co dot 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";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-13 05:44 UTC]
$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
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 19:01:31 2024 UTC