Re: Problem with variable functions

From: Date: Wed, 12 Jul 2000 18:35:16 +0000
Subject: Re: Problem with variable functions
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-6215@lists.php.net to get a copy of this message
* Charles Killian wrote: > So if $$function() still doesn't work, here's my example corrected: > $function = "\$classname->sett" > call_user_func($$function); Didn't work either: Warning: Unable to call (null)() - function does not exist in ... But I found a solution: if (preg_match('=^\$(.*)->(.*)=si',$function,$tokens)) { $object = $tokens[1]; $method = $tokens[2]; $ersatzstr = call_user_method($method,$$object,$params); } else { $ersatzstr = call_user_func($function,$params); } This works now. Björn.

« previous php.general (#6215) next »