#44484 [NEW]: Call to magic function __toString gives a undefined method error
From: jochem dot blok at fasterforward dot nl
Operating system: Windows XP SP2
PHP version: 5.2.5
PHP Bug Type: SimpleXML related
Bug description: Call to magic function __toString gives a undefined method error
Description:
------------
The call to magic function __toString() gives a Fatal error. This method
should exists, see the reply of helly@php.net at
http://bugs.php.net/bug.php?id=25640
Reproduce code:
---------------
<?php
$xmlstr = <<<XML
<?xml version='1.0' standalone='yes'?>
<movies>
<movie>
<title>PHP: Behind the Parser</title>
<characters>
<character>
<name>Ms. Coder</name>
<actor>Onlivia Actora</actor>
</character>
<character>
<name>Mr. Coder</name>
<actor>El ActÓr</actor>
</character>
</characters>
<plot>
So, this language. It's like, a programming language. Or is it a
scripting language? All is revealed in this thrilling horror spoof
of a documentary.
</plot>
<great-lines>
<line>PHP solves all my web problems</line>
</great-lines>
<rating type="thumbs">7</rating>
<rating type="stars">5</rating>
</movie>
</movies>
XML;
$xml = new SimpleXMLElement($xmlstr);
$m = $xml->movie[0]->plot; // "So this language. It's like..."
$m->__toString()
?>
Expected result:
----------------
So, this language. It's like, a programming language. Or is it a
scripting language? All is revealed in this thrilling horror spoof
of a documentary.
Actual result:
--------------
Fatal error: Call to undefined method SimpleXMLElement::__toString() in
C:\php\xml.php on line 35
--
Edit bug report at http://bugs.php.net/?id=44484&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44484&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44484&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44484&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44484&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=44484&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44484&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44484&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44484&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44484&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44484&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=44484&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=44484&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44484&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44484&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44484&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44484&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44484&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44484&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44484&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44484&r=mysqlcfg
Thread (3 messages)
- jochem dot blok at fasterforward dot nl