XML_Tree + PHP5
| From: | daniel at electroteque dot org | Date: | Thu, 04 Nov 2004 00:31:31 +0000 |
| Subject: | XML_Tree + PHP5 | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-15325@lists.php.net to get a copy of this message | ||
hi again I have looked at the code and there is some strange changes with
the clone functions
function cloneTree()
{
$clone = new XML_Tree($this->filename, $this->version);
if (!is_null($this->root)) {
$clone->root = $this->root->cloneTree();
}
// clone all other vars
$temp = get_object_vars($this);
foreach($temp as $varname => $value) {
if
(!in_array($varname,array('filename','version','root'))) {
$clone->$varname=$value;
}
}
return $clone;
}
this is in Tree.php
and this is in Node.php
/**
* clone node and all its children (recursive)
*
* @return object reference to the clone-node
*/
function &clone() {
$clone=new
XML_Tree_Node($this->name,$this->content,$this->attributes);
$max_child=count($this->children);
for($i=0;$i<$max_child;$i++) {
$clone->children[]=$this->children[$i]->clone();
}
/* for future use....
// clone all other vars
$temp=get_object_vars($this);
foreach($temp as $varname => $value)
if
(!in_array($varname,array('name','content','attributes','children')))
$clone->$varname=$value;
*/
return($clone);
}