Jump to content

A variable function call based on database field value


NeoMarine

Recommended Posts

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.

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");

Archived

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

×
×
  • Create New...

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.