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'? 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();' ? 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] 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. Link to comment https://forums.phpfreaks.com/topic/7782-echo-a-function/#findComment-28754 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.