From: jordan dot raub at dataxltd dot com Operating system: linux PHP version: 5.2.8 PHP Bug Type: SimpleXML related Bug description: Extending SimplXMLElement (or Iterator) w/ __toString
Description: ------------ implicit call to __toString() for the extended class does not work properly an empty value is returned (even without the try catch block nothing is returned) Reproduce code: --------------- <?php class XML extends SimpleXMLElement { public function __toString() { try { $xml = new DOMDocument('1.0', 'utf-8'); $xml->formatOutput = TRUE; $xml->preserveWhiteSpace = FALSE; $xml->loadXML($this->asXML()); $retval = $xml->saveXML(); } catch(Exception $e) { $retval = ''; } return $retval; } } $xml = new XML('<foo><bar/></foo>'); echo '|' . $xml . "|\n"; echo '|' . (string) $xml . "|\n"; echo '|' . $xml->__toString() . "|\n"; Expected result: ---------------- |<?xml version="1.0"?> <foo> <bar/> </foo> | |<?xml version="1.0"?> <foo> <bar/> </foo> | |<?xml version="1.0"?> <foo> <bar/> </foo> | Actual result: -------------- || || |<?xml version="1.0"?> <foo> <bar/> </foo> | -- Edit bug report at http://bugs.php.net/?id=46968&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46968&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46968&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46968&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=46968&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=46968&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=46968&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=46968&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=46968&r=needscript Try newer version: http://bugs.php.net/fix.php?id=46968&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=46968&r=support Expected behavior: http://bugs.php.net/fix.php?id=46968&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=46968&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=46968&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=46968&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46968&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=46968&r=dst IIS Stability: http://bugs.php.net/fix.php?id=46968&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=46968&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=46968&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=46968&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=46968&r=mysqlcfg