note 14389 added to keyword.paamayim_nekudotayim.php
| From: | () | Date: | Sun, 29 Jul 2001 08:38:03 +0000 |
| Subject: | note 14389 added to keyword.paamayim_nekudotayim.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-16017@lists.php.net to get a copy of this message | ||
And now, encapsulated in constructor. Isn't it nice? Ye, and it WILL work when more objects
of class are serialized & unserialized ONLY when serialized in array / hash by one serialize()
call - as serialize() should be used. However, when unserialized, it doesn't affect actual
instances' "static" variable - thus, there will be 2 or more static variables after
unserialization... but you can still change __wakeup() and to access "real"(actual)
class' static value's reference, thus you have to use special function for every static
value, as in example above... Ye, PHP is good!@
<?
class O {
function O() {
static $statValue=0;
$this->statValue= &$statValue;
}
}
$o1= &new O;
$o2= &new O;
echo "\$o1: ".$o1->statValue."<br>";
echo "\$o2: ".$o2->statValue."<br>";
$o1->statValue= 5;
$o2->statValue= 10;
echo "\$o1: ".$o1->statValue."<br>";
echo "\$o2: ".$o2->statValue."<br>";
?>
http://www.php.net/manual/en/keyword.paamayim_nekudotayim.php