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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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: Thu Dec 12 01:01:28 2024 UTC