note 109110 added to language.oop5.visibility
| From: | jc dot flash at gmail dot com | Date: | Thu, 21 Jun 2012 02:31:26 +0000 |
| Subject: | note 109110 added to language.oop5.visibility | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188728@lists.php.net to get a copy of this message | ||
if not overwritten, self::$foo in a subclass actually refers to parent's self::$foo
<?php
class one
{
protected static $foo = "bar";
public function change_foo($value)
{
self::$foo = $value;
}
}
class two extends one
{
public function tell_me()
{
echo self::$foo;
}
}
$first = new one;
$second = new two;
$second->tell_me(); // bar
$first->change_foo("restaurant");
$second->tell_me(); // restaurant
?>
----
Server IP: 69.147.83.197
Probable Submitter: 195.14.156.34
----
Manual Page -- http://www.php.net/manual/en/language.oop5.visibility.php
Edit -- https://master.php.net/note/edit/109110
Del: integrated -- https://master.php.net/note/delete/109110/integrated
Del: useless -- https://master.php.net/note/delete/109110/useless
Del: bad code -- https://master.php.net/note/delete/109110/bad+code
Del: spam -- https://master.php.net/note/delete/109110/spam
Del: non-english -- https://master.php.net/note/delete/109110/non-english
Del: in docs -- https://master.php.net/note/delete/109110/in+docs
Del: other reasons-- https://master.php.net/note/delete/109110
Reject -- https://master.php.net/note/reject/109110
Search -- https://master.php.net/manage/user-notes.php