note 94604 deleted from language.oop5.constants by cmb

From: Date: Wed, 31 Aug 2016 17:13:13 +0000
Subject: note 94604 deleted from language.oop5.constants by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206437@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- Note that since constants are tied to the class definition, they are static by definition and cannot be accessed using the -> operator. A side effect of this is that it's entirely possible for a class constant to have the same name as a property (static or object): <?php class Foo { const foo = 'bar'; public $foo = 'foobar'; const bar = 'foo'; static $bar = 'foobar'; } var_dump(foo::$bar); // static property var_dump(foo::bar); // class constant $bar = new Foo(); var_dump($bar->foo); // object property var_dump(bar::foo); // class constant ?>

« previous php.notes (#206437) next »