#49085 [Opn->Bgs]: Typo in code example

From: Date: Tue, 28 Jul 2009 09:22:49 +0000
Subject: #49085 [Opn->Bgs]: Typo in code example
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-2564@lists.php.net to get a copy of this message
ID: 49085 Updated by: rquadling@php.net Reported By: asukakenji at gmail dot com -Status: Open +Status: Bogus Bug Type: Documentation problem Operating System: N/A PHP Version: Irrelevant New Comment: Adding another movie to the movies collection and then running the example works as expected. <?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> <movie> <title>Upfront and personal</title> <characters> <character> <name>Richardo</name> <actor>Richard Quadling</actor> </character> <character> <name>Ozzer</name> <actor>Oscar Quadling</actor> </character> </characters> <plot> With only a few days to go, they get the job done. </plot> <great-lines> <line>A monkey could have done it!</line> </great-lines> <rating type="thumbs">9</rating> <rating type="stars">6</rating> </movie> </movies> XML; $xml = new SimpleXMLElement($xmlstr); /* For each <movie> node, we echo a separate <plot>. */ foreach ($xml->movie as $movie) { echo $movie->plot, PHP_EOL; } ?> outputs ... 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. With only a few days to go, they get the job done. Previous Comments: ------------------------------------------------------------------------ [2009-07-28 06:29:36] asukakenji at gmail dot com Description: ------------ There is a typo in the code example. Reproduce code: --------------- Visit: http://www.php.net/manual/en/simplexml.examples-basic.php Expected result: ---------------- In example #4, line 7, it should be: foreach ($xml->movies as $movie) { Actual result: -------------- This is shown instead (the first movie should be movies): foreach ($xml->movie as $movie) { ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49085&edit=1

« previous php.doc.bugs (#2564) next »