note 103916 deleted from language.oop5.constants by danbrown

From: Date: Wed, 11 May 2011 15:43:15 +0000
Subject: note 103916 deleted from language.oop5.constants by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-179621@lists.php.net to get a copy of this message
Note Submitter: ma75bo at gmail dot com ---- @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' ?>

« previous php.notes (#179621) next »