note 94604 added to language.oop5.constants
| From: | Anonymous at osu1 dot php dot net | Date: | Fri, 13 Nov 2009 20:03:06 +0000 |
| Subject: | note 94604 added to language.oop5.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-162879@lists.php.net to get a copy of this message | ||
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
?>
----
Server IP: 64.71.164.2
Probable Submitter: 67.237.238.105
----
Manual Page -- http://www.php.net/manual/en/language.oop5.constants.php
Edit -- https://master.php.net/note/edit/94604
Del: integrated -- https://master.php.net/note/delete/94604/integrated
Del: useless -- https://master.php.net/note/delete/94604/useless
Del: bad code -- https://master.php.net/note/delete/94604/bad+code
Del: spam -- https://master.php.net/note/delete/94604/spam
Del: non-english -- https://master.php.net/note/delete/94604/non-english
Del: in docs -- https://master.php.net/note/delete/94604/in+docs
Del: other reasons-- https://master.php.net/note/delete/94604
Reject -- https://master.php.net/note/reject/94604
Search -- https://master.php.net/manage/user-notes.php