How to access the per-class constant from a member function?
| From: | Kamesh Jayachandran | Date: | Wed, 28 Jul 2004 13:32:01 +0000 |
| Subject: | How to access the per-class constant from a member function? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-11592@lists.php.net to get a copy of this message | ||
Hi All,
<?php
class Foo {
const HELLO = "con\n";
function memberfunc() {
echo HELLO; //does not work
echo Foo::HELLO; //works
}
}
$obj = new Foo();
$obj->memberfunc();
?>
With a error_reporting=2047 I get
Notice: Use of undefined constant HELLO - assumed 'HELLO' in
/rekha/php-5.0.0/test.php on line 5
Whey echo HELLO fails?
With regards
Kamesh Jayachandran