Re: Get name of extending class with static method call

From: Date: Wed, 12 Jan 2005 09:21:12 +0000
Subject: Re: Get name of extending class with static method call
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-206153@lists.php.net to get a copy of this message
"Jason Barnett" <jason.barnett@telesuite.com> wrote in message news:20050111192629.21621.qmail@pb1.pair.com... > The only other solution that comes to mind is a little messy but it lets > you get away with no object. Instead of calling the method statically > you can use call_user_func_array() with the child class name as a > parameter. Then change the parent method to accept the child class name > as a parameter. > > <?php > > function call_static_child() { > $drive_args = func_get_args(); > /** assume that first parameter is child of class Car */ > return call_user_func_array(array($drive_args[0], 'drive'), $drive_args); > } > > ?> Hi Jason, thanks for taking a look but there *must* be a way to achieve this without passing any parameters around. Otherwise I could just do: Porsche::drive('Porsche'); Best regards, Torsten

« previous php.general (#206153) next »