PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
$someVarible;
function foo()
{
global $someVariable;
$someVariable = "bar";
}
?>
I think that would make it so I only have to define it once as global instead of in the case of my script where there are 20 some variables and the list has to be maintained both inside and outside the function...
yeah you should consider passing the variables through the function itself.
that way you dont need to change your functions if you ever change the name of the variable.
i almost never use the global statement inside of a function,
if i need to do that i always feel im not using functions correctly.
theres def exceptions but i havent found many.
if you need to call global on a ton of variables inside a function,
maybe consider using an include so your code will inherit the scope and there will be no need for calling global then...
but to answer your initial question, no, there is no way to declare a variable as a superglobal.
however, you could put the variable into an existing superglobal like _SESSION, but thats
a really smurfy way to do things....
use functions how they were meant to be used, pass variables through the function itself.