cjb Posted April 18, 2006 Share Posted April 18, 2006 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'? Quote Link to comment https://forums.phpfreaks.com/topic/7782-echo-a-function/ Share on other sites More sharing options...
ypirc Posted April 18, 2006 Share Posted April 18, 2006 Did you 'echo $function();' ? Quote Link to comment https://forums.phpfreaks.com/topic/7782-echo-a-function/#findComment-28379 Share on other sites More sharing options...
Barand Posted April 18, 2006 Share Posted April 18, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/7782-echo-a-function/#findComment-28395 Share on other sites More sharing options...
cjb Posted April 19, 2006 Author Share Posted April 19, 2006 Barand,That worked, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/7782-echo-a-function/#findComment-28754 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.