Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10020 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33149 invoked by uid 1010); 22 May 2004 00:36:26 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 33111 invoked from network); 22 May 2004 00:36:26 -0000 Received: from unknown (HELO iko.gotobg.net) (80.168.8.116) by pb1.pair.com with SMTP; 22 May 2004 00:36:26 -0000 Received: from pd95e9c4e.dip.t-dialin.net ([217.94.156.78] helo=hristov.com) by iko.gotobg.net with asmtp (Exim 4.24) id 1BRKV5-0006AO-Br; Sat, 22 May 2004 03:36:31 +0300 Message-ID: <40AE9FF0.30008@hristov.com> Date: Sat, 22 May 2004 02:33:52 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20031230 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Daniel J Cain Jr." , internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - iko.gotobg.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - hristov.com Subject: Re: [PHP-DEV] PHP5: expected __METHOD__ behavior From: php@hristov.com (Andrey Hristov) Daniel J Cain Jr. wrote: > I am by no means an expert with OOP, so if this is a blatantly retarded > question please excuse my ignorance. > > Given this code: > > class A > { > function foo() > { > echo __METHOD__; > } > } > > class B > { > function bar() > { > // blah > } > } > > $instance = B::foo(); > ?> > > output is "A::foo". > > Is this correct? I would expect (want maybe :) ) to see output as > "B::foo". If you need more information please let me know. > > TIA > > -dan > Hi, this "constant" like the others is resolved on compile time. Another example is __CLASS__: php -r 'class a{ function c() {var_dump(__CLASS__);}}class b extends a{};$a=new b();$a->c();' dumps : string(1) "a" __METHOD__ is resolved as __CLASS__.'::'.__FUNCTION__ IMO the current behaviour is the normal since works like the C preprocessor doing substitutions before compile (PHP does it while compiling). You can get what you wanted with this : echo get_class($this).'::'.__FUNCTION__ (when there is an instance of the class) but AFAIK in your case with static calls there is no solution. Cheers, Andrey