note 108938 added to language.oop5.cloning
| From: | seriously at something dot com | Date: | Wed, 06 Jun 2012 16:58:10 +0000 |
| Subject: | note 108938 added to language.oop5.cloning | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188425@lists.php.net to get a copy of this message | ||
If you want a property that gets the same value in every clone if changed, you can do this simple
trick:
<?php
class A
{
public static $name ;
}
$a = new A;
$a::$name = 'George';
$b = clone $a;
$b::$name = "Somebody else";
echo 'a: ' . $a::$name . "\n";
echo 'b: ' . $b::$name . "\n";
?>
this will output:
a: Somebody else
b: Somebody else
You can change any of the clones property and all of the others will change accordingly.
----
Server IP: 69.147.83.197
Probable Submitter: 129.128.136.52
----
Manual Page -- http://www.php.net/manual/en/language.oop5.cloning.php
Edit -- https://master.php.net/note/edit/108938
Del: integrated -- https://master.php.net/note/delete/108938/integrated
Del: useless -- https://master.php.net/note/delete/108938/useless
Del: bad code -- https://master.php.net/note/delete/108938/bad+code
Del: spam -- https://master.php.net/note/delete/108938/spam
Del: non-english -- https://master.php.net/note/delete/108938/non-english
Del: in docs -- https://master.php.net/note/delete/108938/in+docs
Del: other reasons-- https://master.php.net/note/delete/108938
Reject -- https://master.php.net/note/reject/108938
Search -- https://master.php.net/manage/user-notes.php