Re: T_PAAMAYIM_NEKUDOTAYIM

From: Date: Mon, 16 Dec 2002 19:55:49 +0000
Subject: Re: T_PAAMAYIM_NEKUDOTAYIM
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-92532@lists.php.net to get a copy of this message
On Mon, 16 Dec 2002, Bertrand Mansion wrote: > <derick@php.net> wrote : > > > It's just not supported by PHP. > > Will it be supported ? Not anytime soon. > This would allow > >> > >>> call_user_func(array($className, 'method'), $param1, $param2); > >> > >> This won't work because, in my case, I don't want to make an instance of > >> $className but rather use $className methods as if they were plugged inside > >> my main object. > > > > This doesn't make an instance at all. > > Sorry, I didn't choose the right way to explain. :) > > I meant that call_user_func needs an instanciated object which I can't > provide as what I really want to do is use a method from a class, not from > an instanciated object. (not sure it's clearer ?) It's as clear as the first try, still, it does not need an instantiated object. but just a classname, see this example: <?php class foo { function method($p1) { echo "$p1\n"; } }; $f = 'foo'; call_user_func(array($f, 'method'), 'foo'); ?> (prints 'foo') > And keep an access to $this from inside the object calling the external > method because my parsing is actually recursive. $this only works for instanciated classes, not static method calls. Derick -- ------------------------------------------------------------------------- Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ -------------------------------------------------------------------------

« previous php.dev (#92532) next »