php.net |  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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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";
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-13 05:44 UTC] hholzgra@php.net
$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: Sun Dec 22 03:01:28 2024 UTC