note 115836 added to domnode.clonenode

From: Date: Wed, 01 Oct 2014 19:48:20 +0000
Subject: note 115836 added to domnode.clonenode
Groups: php.notes 
Request: Send a blank email to php-notes+get-200560@lists.php.net to get a copy of this message
If you have an object that holds a DOMNode, cloning the object won't clone the DOMNode with it. If you simply copy the object or add its DOMNode several times, you will in fact only move the DOMNode in the tree, not multiply it. That might seem obvious, but took me half a day to find out. The object needs to use __clone and clone the node manually: <?php class containsNode { public $node; //set from somewhere public function __clone() { $this->node = $this->node->cloneNode(TRUE); } } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 189.100.99.191 ---- Manual Page -- http://php.net/manual/en/domnode.clonenode.php Edit -- https://master.php.net/note/edit/115836 Del: integrated -- https://master.php.net/note/delete/115836/integrated Del: useless -- https://master.php.net/note/delete/115836/useless Del: bad code -- https://master.php.net/note/delete/115836/bad+code Del: spam -- https://master.php.net/note/delete/115836/spam Del: non-english -- https://master.php.net/note/delete/115836/non-english Del: in docs -- https://master.php.net/note/delete/115836/in+docs Del: other reasons-- https://master.php.net/note/delete/115836 Reject -- https://master.php.net/note/reject/115836 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200560) next »