note 87066 added to language.oop5.cloning

From: Date: Tue, 18 Nov 2008 13:15:27 +0000
Subject: note 87066 added to language.oop5.cloning
Groups: php.notes 
Request: Send a blank email to php-notes+get-146638@lists.php.net to get a copy of this message
Want deep cloning without too much hassle? function __clone() { foreach($this as $key => $val) { if(is_object($val)||(is_array($val))){ $this->{$key} = unserialize(serialize($val)); } } } That will insure any object, or array that may potentially contain objects, will get cloned without using recursion or other support methods. ---- Server IP: 69.147.83.197 Probable Submitter: 72.29.217.82 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.cloning.php Edit -- https://master.php.net/note/edit/87066 Del: integrated -- https://master.php.net/note/delete/87066/integrated Del: useless -- https://master.php.net/note/delete/87066/useless Del: bad code -- https://master.php.net/note/delete/87066/bad+code Del: spam -- https://master.php.net/note/delete/87066/spam Del: non-english -- https://master.php.net/note/delete/87066/non-english Del: in docs -- https://master.php.net/note/delete/87066/in+docs Del: other reasons-- https://master.php.net/note/delete/87066 Reject -- https://master.php.net/note/reject/87066 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#146638) next »