Forum Moderators: coopster
Is there some way to not have to globalize every variable I want to use? Because I may be adding, deleting, or changing variables.
For example:
function some_func()
{
global $any_variable_i_want_to_use_in_here;
a bunch of code
}
instead of have to do global $any_variable_i_want_to_use_in_here; is there a way I can make the function public or use any variable available?
Thanks for your help.
If you want to explode the globals inside your function, you could keep most of your code the same after modifying the global line and adding the explode code.
I am interested in hearing other people's thoughts on this and other ideas.
?><pre><? echo "\$GLOBALS ="; print_r($GLOBALS);?></pre><? in your script to see what variables are avilable to you in this way.
Let me try to clarify what I was asking.
Lets say I call a function in my php code:
some_func();
Lets say before some function I have a variable:
$some_variable
If I want to use that variable in my function I have to do this:
function some_func()
{
global $some_variable;
function code
}
The problem is that in the function I use the eval() function. So it evaluates anything i pass into the eval() function and whatever I pass into the eval() function could contain basically any variable in my code. The variables are going to be different in every instance and will probably contain quite a few variables. So instead of having to global hundreds of variables I was wondering if there was a way to make the function accept any variables without having to global variables.
I hope this clarifies what I was asking.