Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:11593 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24761 invoked by uid 1010); 28 Jul 2004 16:10:51 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 24663 invoked from network); 28 Jul 2004 16:10:51 -0000 Received: from unknown (HELO mail.keliglia.com) (81.57.253.132) by pb1.pair.com with SMTP; 28 Jul 2004 16:10:51 -0000 Received: (qmail 28 invoked from network); 28 Jul 2004 16:13:45 -0000 Received: from m121.net81-64-251.noos.fr (HELO ?192.168.123.101?) (didou@keliglia.com@81.64.251.121) by voltaire-4-81-57-253-132.fbx.proxad.net with SMTP; 28 Jul 2004 16:13:45 -0000 Message-ID: <4107D00C.4050505@php.net> Date: Wed, 28 Jul 2004 18:10:52 +0200 User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kamesh Jayachandran CC: internals@lists.php.net References: <1091021521.30562.201240234@webmail.messagingengine.com> In-Reply-To: <1091021521.30562.201240234@webmail.messagingengine.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: How to access the per-class constant from a member function? From: didou@php.net (Mehdi Achour) 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, > 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