Re: Calling a string as a function
| From: | Ron Rudman | Date: | Mon, 14 Apr 2003 23:34:27 +0000 |
| Subject: | Re: Calling a string as a function | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143846@lists.php.net to get a copy of this message | ||
eval() is a bit tricky, since it demands a complete, valid, php statement
(unlike JavsScript or VBScript).
So, if $f is your string:
eval( $f . ';' ) will work.
If you need the result of the funcation cal:
eval( '$foo = ' . $f . ';' );
and then reference $foo.
"Lasse Laursen" <laursen@netgroup.dk> wrote in message
news:12ca01c3013c$3d18b200$7e01000a@animal...
> Hi all,
>
> I hope that someone can answer this:
>
> I have some stings stored in a database, eg:
>
> "my_function($some_var, $some_other_var)"
> "another_function($a, $b, $c)"
>
> etc. - depending on various things I would like to call one of the
> variables. I have pulled the string out from the database and stored it in
a
> $function variable.
>
> How can I call the sting as a function?
>
> Regards
> --
> Lasse Laursen <laursen@netgroup.dk> - Systems Developer
> NetGroup A/S, St. Kongensgade 40H, DK-1264 København K, Denmark
> Phone: +45 3370 1526 - Fax: +45 3313 0066 - Web: www.netgroup.dk
>
> - Don't be fooled by cheap finnish imitations ; BSD is the One True Code
>
>