note 114932 added to language.oop5.cloning
| From: | obaidmaroof at gmail dot com | Date: | Tue, 29 Apr 2014 14:01:20 +0000 |
| Subject: | note 114932 added to language.oop5.cloning | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199369@lists.php.net to get a copy of this message | ||
<?php
class A{
public $my_var;
function __construct() { $this->my_var = 'aaa'; }
}
$a = new A;
$b = clone $a;
$b->my_var = 'bbb';
echo($a->my_var); // 'aaa'
echo($b->my_var); // 'bbb'
$c = new A;
$d = $c;
$d->my_var = 'bbb';
echo($c->my_var); // 'bbb'
echo($d->my_var); // 'bbb'
?>
simple example to understand the basic concept behind clone.
----
Server IP: 72.52.91.14
Probable Submitter: 212.18.223.39
----
Manual Page -- http://php.net/manual/en/language.oop5.cloning.php
Edit -- https://master.php.net/note/edit/114932
Del: integrated -- https://master.php.net/note/delete/114932/integrated
Del: useless -- https://master.php.net/note/delete/114932/useless
Del: bad code -- https://master.php.net/note/delete/114932/bad+code
Del: spam -- https://master.php.net/note/delete/114932/spam
Del: non-english -- https://master.php.net/note/delete/114932/non-english
Del: in docs -- https://master.php.net/note/delete/114932/in+docs
Del: other reasons-- https://master.php.net/note/delete/114932
Reject -- https://master.php.net/note/reject/114932
Search -- https://master.php.net/manage/user-notes.php