|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33986 Using $simpleXMLElement->node as string cause bug
Submitted: 2005-08-03 21:04 UTC Modified: 2005-08-03 22:05 UTC
From: kulev dot vladimir at gmail dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.1.0b3 OS: Gentoo Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: kulev dot vladimir at gmail dot com
New email:
PHP Version: OS:


 [2005-08-03 21:04 UTC] kulev dot vladimir at gmail dot com
Maybe it's ok, because $root->node is not a string, but object.
But then PHP must return error when trying to do so, I think.

Reproduce code:
$xml = "<root><node>data</node></root>";
$root = simplexml_load_string($xml);
$str = $root->node;
echo "'" . $str . "'<br/>\n";
echo "'" . $str{0} . "'<br/>\n";
echo "'" . $str{1} . "'<br/>\n";
$str = strval($root->node);
echo "'" . $str . "'<br/>\n";
echo "'" . $str{0} . "'<br/>\n";
echo "'" . $str{1} . "'<br/>\n";

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-03 22:05 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

$str = $root->node; 
echo \"\'\" . $str{0} . \"\'<br/>\\n\"; 
is the same as 
echo \"\'\" . $str[0] . \"\'<br/>\\n\"; 
so the first node is fetched whos value is \"data\". 
$str[1]\'s value NULL since there\'s only one node. 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 07:01:27 2024 UTC