note 103023 added to language.oop5.late-static-bindings
| From: | vk at osu1 dot php dot net | Date: | Mon, 21 Mar 2011 08:32:57 +0000 |
| Subject: | note 103023 added to language.oop5.late-static-bindings | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178039@lists.php.net to get a copy of this message | ||
Unexpected features:
<?php
class A{
protected static $bar='A';
function foo(){
echo static::$bar;
}
}
class B extends A{
protected static $bar='B';
}
B::foo();
?>
Will output: B
BUT:
<?php
class A{
protected static $bar='A';
function foo(){
echo static::$bar;
}
}
class B extends A{
protected static $bar='B';
}
//Added
class C{
function __construct(){
B::foo();
}
}
$C = new C();
?>
Will produce:
Fatal error: Access to undeclared static property: C::$bar in file on line 5
----
Server IP: 69.147.83.197
Probable Submitter: 89.232.252.174
----
Manual Page -- http://www.php.net/manual/en/language.oop5.late-static-bindings.php
Edit -- https://master.php.net/note/edit/103023
Del: integrated -- https://master.php.net/note/delete/103023/integrated
Del: useless -- https://master.php.net/note/delete/103023/useless
Del: bad code -- https://master.php.net/note/delete/103023/bad+code
Del: spam -- https://master.php.net/note/delete/103023/spam
Del: non-english -- https://master.php.net/note/delete/103023/non-english
Del: in docs -- https://master.php.net/note/delete/103023/in+docs
Del: other reasons-- https://master.php.net/note/delete/103023
Reject -- https://master.php.net/note/reject/103023
Search -- https://master.php.net/manage/user-notes.php