Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.