Jump to content

Functions Created in eval()


Eddy999999

Recommended Posts

I am trying to be able to execute portions of code stored in a database using eval(). My question is, if I create a function inside of an eval() statement, can it be executed from code outside of the eval statement. For example, if I have the following code in my database:

 

function test() { echo 'test'; }

 

And retrieve it from the database as $test, and have this code:

 

eval($test);
test();

 

Should the function call work correctly? The reason I ask is because when I tried to do this, I got a "Call to undefined function:" error, and I'm trying to figure out if it's something I did wrong, or if I just can't do that.

 

Any help, or links to somewhere with some info, would be greatly appreciated, although I wasn't able to find anything that helped with a quick google search.

 

Thanks,

Eddy

Link to comment
https://forums.phpfreaks.com/topic/51092-functions-created-in-eval/
Share on other sites

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.