Re: __call and recursion

From: Date: Sun, 09 May 2010 21:25:45 +0000
Subject: Re: __call and recursion
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-305027@lists.php.net to get a copy of this message
On 9 May 2010 23:21, Daniel Kolbo <kolb0057@umn.edu> wrote: > Hello, > > I've defined a __call() method inside a class.  Within the __call() > method (after testing that the method exists and is callable I am using: > > call_user_func_array(array($this,$method), $args); > > However, this seems to be an infinite loop (and is crashing my test > apache server).  How, could I still use the __call() method and avoid an > infinite loop of calling? Assuming that your __call() method was reached because no $method was defined, using call_user_func_array() to call $method on the same object is going to result in ... your __call() method getting called again. You need to map the $method to whichever class methods you *actually* want to call, instead of blindly trying to reissue the call. Regards Peter -- <hype> WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind Flickr: http://www.flickr.com/photos/fake51 BeWelcome: Fake51 Couchsurfing: Fake51 </hype>

« previous php.general (#305027) next »