#44484 [Opn->Asn]: Call to magic function __toString gives a undefined method error

From: Date: Wed, 19 Mar 2008 18:58:18 +0000
Subject: #44484 [Opn->Asn]: Call to magic function __toString gives a undefined method error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-123485@lists.php.net to get a copy of this message
ID: 44484 Updated by: colder@php.net Reported By: jochem dot blok at fasterforward dot nl -Status: Open +Status: Assigned Bug Type: SimpleXML related Operating System: Windows XP SP2 PHP Version: 5.2.5 Assigned To: colder Previous Comments: ------------------------------------------------------------------------ [2008-03-19 17:39:15] jochem dot blok at fasterforward dot nl 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&#211;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 this bug report at http://bugs.php.net/?id=44484&edit=1

« previous php.bugs (#123485) next »