#29500 [Opn->WFx]: Accessing object elements returns object
| From: | chregu@php.net | Date: | Tue, 03 Aug 2004 10:01:14 +0000 |
| Subject: | #29500 [Opn->WFx]: Accessing object elements returns object | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-64007@lists.php.net to get a copy of this message | ||
ID: 29500
Updated by: chregu@php.net
Reported By: lists at cyberlot dot net
-Status: Open
+Status: Wont fix
Bug Type: SimpleXML related
Operating System: Fedora Core 2
PHP Version: 5.0.0
New Comment:
That's by design and was discussed on
internals@lists.php.net
Previous Comments:
------------------------------------------------------------------------
[2004-08-03 05:23:22] lists at cyberlot dot net
http://us3.php.net/manual/en/ref.simplexml.php
In trying to get this working I played with the examples from this
page.
Example 7 returns the following error
Fatal error: Objects used as arrays in post/pre increment/decrement
must return values by reference in /root/test.php on line 29
------------------------------------------------------------------------
[2004-08-03 05:15:42] lists at cyberlot dot net
Description:
------------
When using simplexml to access a element the returned object it returns
a object instead of a string
Have to type cast it as a (string) to get the information back, Should
not have to typecast.
If a typecast is required it should be specificed in the docs.
Reproduce code:
---------------
$string = <<<XML
<?xml version='1.0'?>
<document>
<cmd>login</cmd>
<login>Richard</login>
</document>
XML;
$xml = simplexml_load_string($string);
print_r($xml);
$login = $xml->login;
print_r($login);
$login = (string) $xml->login;
print_r($login);
Expected result:
----------------
SimpleXMLElement Object
(
[cmd] => login
[login] => Richard
)
Richard
Richard
Actual result:
--------------
SimpleXMLElement Object
(
[cmd] => login
[login] => Richard
)
SimpleXMLElement Object
(
[0] => Richard
)
Richard
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29500&edit=1