Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:14361 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46405 invoked by uid 1010); 12 Jan 2005 17:43:01 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 46360 invoked from network); 12 Jan 2005 17:43:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jan 2005 17:43:00 -0000 X-Host-Fingerprint: 66.92.75.243 dsl092-075-243.bos1.dsl.speakeasy.net Linux 2.4/2.6 Received: from ([66.92.75.243:1358] helo=amber.vis-av.com) by pb1.pair.com (ecelerity HEAD (r4059)) with SMTP id 17/F5-09312-1A165E14 for ; Wed, 12 Jan 2005 12:42:58 -0500 Received: (qmail 1466 invoked from network); 12 Jan 2005 17:35:24 -0000 Received: from unknown (HELO random.internal) (192.168.1.9) by amber.internal with SMTP; 12 Jan 2005 17:35:24 -0000 Received: (nullmailer pid 22314 invoked by uid 0); Wed, 12 Jan 2005 17:35:24 -0000 To: Torsten Roehr Cc: internals@lists.php.net References: <20050112155751.33379.qmail@pb1.pair.com> Reply-To: Derrell.Lipman@UnwiredUniverse.com Date: Wed, 12 Jan 2005 12:35:24 -0500 In-Reply-To: <20050112155751.33379.qmail@pb1.pair.com> (Torsten Roehr's message of "Wed, 12 Jan 2005 16:58:20 +0100") Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Corporate Culture, linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [PHP-DEV] Get name of extending class with static method call (PHP5) From: Derrell.Lipman@UnwiredUniverse.com "Torsten Roehr" writes: > Hi devs, > > after a long discussion on php-general [1], searching the archives and > trying every proposed solution without success I'm asking for your help to > solve the following problem: > > class Car { > function drive() { > // I need the name of the calling class here > // in my case it should be 'Porsche' > } > } > > class Porsche extends Car { > } > > Porsche::drive(); You're previous thread says that you want drive() to be static, but you're not declaring it static. If it needn't be static, then you can do this: class Car { function drive() { echo get_class($this) . "\n"; } } class Porsche extends Car { } $carType = new Porsche(); $carType->drive();