NeoMarine Posted January 17, 2010 Share Posted January 17, 2010 Hello, In my database I have a field where I store a value such as "myfunction($param1value="1",$param2value="2",$param3value="3");" What I want to do, is to basically use that value and execute the function on a php page, like: $mysqlValue="myfunction($param1value="1",$param2value="2",$param3value="3");"; $mysqlValue(); // only with the parameter values and everything in otherwords, I want to get the following to execute: <?php myfunction($param1value="1",$param2value="2",$param3value="3"); ?> ANY IDEAS? Is this possible? I am aware of variable functions but that doesn't seem to support parameter values in the string(variable)-to-function. Quote Link to comment https://forums.phpfreaks.com/topic/188797-a-variable-function-call-based-on-database-field-value/ Share on other sites More sharing options...
wildteen88 Posted January 17, 2010 Share Posted January 17, 2010 PHP will treat all code stored in your database as plain text. You'll have to use eval to execute the code you have stored in your database. eg $mysqlValue='myfunction($param1value="1",$param2value="2",$param3value="3");'; eval("$mysqlValue"); Quote Link to comment https://forums.phpfreaks.com/topic/188797-a-variable-function-call-based-on-database-field-value/#findComment-996750 Share on other sites More sharing options...
NeoMarine Posted January 17, 2010 Author Share Posted January 17, 2010 Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/188797-a-variable-function-call-based-on-database-field-value/#findComment-996867 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.