note 103916 added to language.oop5.constants
| From: | ma75bo at gmail dot com | Date: | Wed, 11 May 2011 07:23:15 +0000 |
| Subject: | note 103916 added to language.oop5.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179592@lists.php.net to get a copy of this message | ||
@narwhal dot jury at gmail dot com:
Sinse v5.3, you may even use the keyword static to reference child constants, static properties or
methods, instead of get_class($this).
<?php
class MyClass {
const MY_CONST = "yonder";
public function __construct() {
echo static::MY_CONST;
}
}
class ChildClass extends MyClass {
const MY_CONST = "bar";
}
$x = new ChildClass(); // prints 'bar'
$y = new MyClass(); // prints 'yonder'
?>
----
Server IP: 69.147.83.197
Probable Submitter: 212.25.27.102
----
Manual Page -- http://www.php.net/manual/en/language.oop5.constants.php
Edit -- https://master.php.net/note/edit/103916
Del: integrated -- https://master.php.net/note/delete/103916/integrated
Del: useless -- https://master.php.net/note/delete/103916/useless
Del: bad code -- https://master.php.net/note/delete/103916/bad+code
Del: spam -- https://master.php.net/note/delete/103916/spam
Del: non-english -- https://master.php.net/note/delete/103916/non-english
Del: in docs -- https://master.php.net/note/delete/103916/in+docs
Del: other reasons-- https://master.php.net/note/delete/103916
Reject -- https://master.php.net/note/reject/103916
Search -- https://master.php.net/manage/user-notes.php