|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-08-21 10:59 UTC] johannes@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 16:00:01 2025 UTC |
Description: ------------ When zend.ze1_compatibility_mode is on, there are clone problems when iterating over the DOMNodelist items With the following code, I get : Fatal error: Cannot clone object of class DOMText due to 'zend.ze1_compatibility_mode' for instance Reproduce code: --------------- <?php ini_set('zend.ze1_compatibility_mode', true); $doc =& new DOMDocument(); $success = $doc->load('/tmp/test.xml'); $root =& $doc->documentElement; $nodeList = &$doc->documentElement->childNodes; for ($i = 0; $i < $nodeList->length; ++$i) { $node = &$nodeList->item($i); echo "$i - "; $nodeName = $node->nodeName; echo "$nodeName :"; $nodeValue = $node->nodeValue; echo "$nodeValue <br/>"; } Expected result: ---------------- I would expect it to display the XML file's contents as without zend.ze1_compatibility_mode (in which case it works) Actual result: -------------- I get "Cannot clone object of class DOMText" wether with : $node = &$nodeList->item($i); or : $node = $nodeList->item($i); a : foreach ($nodeList as $node) { echo $node->nodeName; echo $node->nodeValue; } won't work either. I guess that the internals of DOMNodelist::item tries to clone them instead of returning them by address, then. Note that : for ($i = 0; $i < $nodeList->length; ++$i) { echo "$i - "; $nodeName = $nodeList->item($i)->nodeName; echo "$nodeName :"; $nodeValue = $nodeList->item($i)->nodeValue; echo "$nodeValue <br/>"; } seems to work, though.