Jump to content

Archived

This topic is now archived and is closed to further replies.

cjb

echo a function()

Recommended Posts

I have a db of functions that are called on a certain criteria. I am trying to get those from the db to be called in a page. I try to [code]echo $function[/code] but all that happens is it prints the text out instead of calling the function 'function();'.

Is there some other way to echo the text function(); from a db other than using 'echo'?

Share this post


Link to post
Share on other sites
Does create_function help?


[code]$row['code'] = 'return sqrt($a*$a + $b*$b);'; // from database

$foo = create_function('$a, $b', $row['code']);

$x = 3;
$y = 4;
echo $foo($x, $y);[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.