|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-10-16 11:49 UTC] php at bouchery dot com
Description:
------------
When using "foreach" on inexisting node, a new node is create.
Reproduce code:
---------------
<?php
$xml = simplexml_load_string('<root><a>Node a</a></root>');
foreach( $xml->b as $b );
echo $xml->asXML();
?>
Expected result:
----------------
<?xml version="1.0"?>
<root><a>Node a</a></root>
Actual result:
--------------
<?xml version="1.0"?>
<root><a>Node a</a><b/></root>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 19:00:01 2025 UTC |
If there is no nodes, I browse like an array, no data is display, but a node was created. If I do it twice, it display something ! Browsing tree MUST NOT create node. Look at this : <?php $xml = simplexml_load_string('<root></root>'); foreach( $xml->a as $a ) echo "a = $a\n"; foreach( $xml->a as $a ) echo "a = $a\n"; ?> A the second time, it display : "a =" Sorry to insist, but it is not "normal" (and I can't see that in the documentation !!).