Re: How to access the per-class constant from a member function?
| From: | Mehdi Achour | Date: | Wed, 28 Jul 2004 16:10:52 +0000 |
| Subject: | Re: How to access the per-class constant from a member function? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-11593@lists.php.net to get a copy of this message | ||
Hi Kamesh,
Try replacing Foo::HELLO with self::HELLO. This should work.
(this is documented, the manual will reflect it in the next build)
didou
Kamesh Jayachandran wrote:
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