Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:11819 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48063 invoked by uid 1010); 2 Aug 2004 13:46:24 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 47935 invoked from network); 2 Aug 2004 13:46:23 -0000 Received: from unknown (HELO out2.smtp.messagingengine.com) (66.111.4.26) by pb1.pair.com with SMTP; 2 Aug 2004 13:46:23 -0000 Received: from server3.messagingengine.com (server3.internal [10.202.2.134]) by mail.messagingengine.com (Postfix) with ESMTP id 9D7C2C13E24; Mon, 2 Aug 2004 09:46:22 -0400 (EDT) Received: by server3.messagingengine.com (Postfix, from userid 99) id 6B6D4184F09; Mon, 2 Aug 2004 09:46:23 -0400 (EDT) Content-Disposition: inline Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 X-Mailer: MIME::Lite 1.4 (F2.72; T1.001; A1.62; B3.01; Q3.01) Cc: internals@lists.php.net References: <1091021521.30562.201240234@webmail.messagingengine.com> <4107D00C.4050505@php.net> In-Reply-To: <4107D00C.4050505@php.net> To: "Mehdi Achour" Date: Mon, 02 Aug 2004 06:46:22 -0700 X-Sasl-Enc: PogrD1HXMa9CwhPgsO7E6A 1091454382 Message-ID: <1091454382.4136.201524319@webmail.messagingengine.com> Subject: Re: How to access the per-class constant from a member function? From: kameshj@fastmail.fm ("Kamesh Jayachandran") Hi Mehdi, Even Foo::HELLO works. My question is why simple HELLO inside a member function does not work. Why are we not able to access the static and const members of a class from inside a class member function like the way with other member variables.? Any special reasons. With regards Kamesh Jayachandran On Wed, 28 Jul 2004 18:10:52 +0200, "Mehdi Achour" said: > 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 >