ID: 48059
Updated by: [email protected]
Reported By: doctorrock83 at gmail dot com
Status: Open
Bug Type: SimpleXML related
Operating System: Win32
PHP Version: 5.2.9
New Comment:
See bug #46968
Previous Comments:
------------------------------------------------------------------------
[2009-04-23 09:27:08] doctorrock83 at gmail dot com
Description:
------------
If I extend SimpleXmlElement and add a __toString() method to it, that
method is not called when I cast my object using (string)$obj.
It is used however on implicit casts (e.g echo $sxmlObj)
Reproduce code:
---------------
class MyXml extends SimpleXMLElement
{
public function __toString()
{
return $this->asXML();
}
public function export()
{
return (string)$this;
}
}
$xml = new MyXml("<xml><some>xml</some></xml>");
echo $xml; // 1
$a = (string)$xml;
echo $a; // 2
echo $xml->export(); // 3
Expected result:
----------------
1 :
xml returned
2 :
xml returned
3:
xml returned
Actual result:
--------------
1 :
OK
2:
nothing is returned
3:
nothing is returned
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48059&edit=1