note 89650 added to language.oop5.static
| From: | davidn at xnet dot co dot nz | Date: | Wed, 18 Mar 2009 00:56:28 +0000 |
| Subject: | note 89650 added to language.oop5.static | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152068@lists.php.net to get a copy of this message | ||
Static variables are shared between sub classes
<?php
class MyParent {
protected static $variable;
}
class Child1 extends MyParent {
function set() {
self::$variable = 2;
}
}
class Child2 extends MyParent {
function show() {
echo(self::$variable);
}
}
$c1 = new Child1();
$c1->set();
$c2 = new Child2();
$c2->show(); // prints 2
?>
----
Server IP: 69.147.83.197
Probable Submitter: 203.109.148.224 (proxied: 203.109.148.224)
----
Manual Page -- http://www.php.net/manual/en/language.oop5.static.php
Edit -- https://master.php.net/note/edit/89650
Del: integrated -- https://master.php.net/note/delete/89650/integrated
Del: useless -- https://master.php.net/note/delete/89650/useless
Del: bad code -- https://master.php.net/note/delete/89650/bad+code
Del: spam -- https://master.php.net/note/delete/89650/spam
Del: non-english -- https://master.php.net/note/delete/89650/non-english
Del: in docs -- https://master.php.net/note/delete/89650/in+docs
Del: other reasons-- https://master.php.net/note/delete/89650
Reject -- https://master.php.net/note/reject/89650
Search -- https://master.php.net/manage/user-notes.php