/**
* Registers global variables
*
* This function takes global namespace $_* variables from input and if they exist,
* register them as a global variable so that scripts can use them. The argument
* signifies where to pull the variable names from, and should be of:
* GET, POST, COOKIE, ENV, or SERVER.
*
*/
function global_register()
{
$num_args = func_num_args();
if ($num_args > 0)
{
for ($i = 0; $i < $num_args; $i++)
{
$method = strtoupper(func_get_arg($i));
if (($method != 'SESSION') && ($method != 'GET') && ($method != 'POST') && ($method != 'SERVER') && ($method != 'COOKIE') && ($method != 'ENV'))
{
die("The \"$method\" is invalid argument, The argument of global_register must be the following: GET, POST, SESSION, SERVER, COOKIE, or ENV");
}
$varname = "_{$method}";
global ${$varname};
foreach (${$varname} as $key => $val)
{
global ${$key};
${$key} = $val;
}
}
}else{ die('You must specifya at least one arguments'); } }
You can then register your global variables for use like this: // register a GET var global_register('GET'); // register GET POST var global_register('GET','POST'); // register GET POST SESSION var global_register('GET','POST','SESSION);
_________________________________________________________________
-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php