dingus Posted April 13, 2008 Share Posted April 13, 2008 ok this is going to stand as a very different question but i would like to load "dynamic" functions where by the functions will be stored in a database i would like to be able to call the php code form the database then exicute it to define a function dose anyone have any idea how i would do that? Quote Link to comment https://forums.phpfreaks.com/topic/100861-dynamic-functions/ Share on other sites More sharing options...
p2grace Posted April 13, 2008 Share Posted April 13, 2008 Why do you want to do this? Quote Link to comment https://forums.phpfreaks.com/topic/100861-dynamic-functions/#findComment-515798 Share on other sites More sharing options...
dingus Posted April 13, 2008 Author Share Posted April 13, 2008 unforchinatly the NDA on the project forbids me from answering that question how ever i can go so fare as to say that the functions will be both user inputed and automatically generated and because they need to be referenced independently i eather need to write each to there own file or load to a database and call from there Quote Link to comment https://forums.phpfreaks.com/topic/100861-dynamic-functions/#findComment-515804 Share on other sites More sharing options...
doni49 Posted April 13, 2008 Share Posted April 13, 2008 www.php.net/eval Quote Link to comment https://forums.phpfreaks.com/topic/100861-dynamic-functions/#findComment-515838 Share on other sites More sharing options...
p2grace Posted April 13, 2008 Share Posted April 13, 2008 Fair enough, as doni49 suggested, the eval function with interpret a string as a php script. It should do the trick for you. Quote Link to comment https://forums.phpfreaks.com/topic/100861-dynamic-functions/#findComment-515842 Share on other sites More sharing options...
dingus Posted April 13, 2008 Author Share Posted April 13, 2008 well that is helpful i just need to know will eval allow me to declare functions? for example $function = 'function cat($str){ return "the cat ".$str"; } eval($function); ? Quote Link to comment https://forums.phpfreaks.com/topic/100861-dynamic-functions/#findComment-515905 Share on other sites More sharing options...
laffin Posted April 13, 2008 Share Posted April 13, 2008 No, but this will function.create-function Quote Link to comment https://forums.phpfreaks.com/topic/100861-dynamic-functions/#findComment-515967 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.