Click to See Complete Forum and Search --> : Class::$func()
amazing_andr3
05-27-2005, 04:17 AM
I need to call a variable function from a class, like this:
$func = 'function';
Class::$func();
However, this produces an error. Any idea how I can do this (or why it doesn't work as I expected)?
Stephen Philbin
05-27-2005, 04:23 AM
What does the error say?
amazing_andr3
05-27-2005, 04:29 AM
<b>Parse error</b>: parse error, expecting `T_STRING'
NogDog
05-27-2005, 04:34 AM
Maybe...
eval("Class::$func();");
...?
Stephen Philbin
05-27-2005, 04:56 AM
Ah. By the looks of it,
$var = new class_name();
$var_func = 'function';
$var->$var_func();
should do it.
Let us know if it's what you wanted.
amazing_andr3
05-27-2005, 05:10 AM
hmmm... actually, it works as I posted initially. lol
the thing was, i made a mistake in the $func variable. then I fixed it, but kept getting the same error because of another mistake later in the code.
sorry