Page 1 of 1

Eval statements in functions.

Posted: Tue Oct 30, 2007 10:25 pm
by Attilitus
scottayy | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Eval statements executed within functions only have access to local variables. For a few classes this has caused me to use code like the following:

Code: Select all

eval($class->method($var));
I would prefer to have the eval statement inside of my function and just use this code:

Code: Select all

$class->method($var);
Any simple way to do this?


scottayy | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Oct 30, 2007 11:52 pm
by Kieran Huggins
maybe the global keyword could help?

Not sure if it would do what you're looking for, but worth a try at any rate.

Posted: Wed Oct 31, 2007 10:29 am
by feyd
A better question may be, why must these things be run through eval()?

Posted: Wed Oct 31, 2007 10:59 am
by Kieran Huggins
indeed

feyd++

Posted: Wed Oct 31, 2007 6:00 pm
by Attilitus
Because vBulletin uses eval to pull templates, and I am not going to be able to convince the entire community to accept my version of the code-base re-written to not use eval.