Registers global variables

From: Date: Sat, 15 Mar 2003 09:57:22 +0000
Subject: Registers global variables
Groups: php.windows 
Request: Send a blank email to php-windows+get-19020@lists.php.net to get a copy of this message
There are a functions posted on this page that can help to make it seem that register_globals is turned on. /** * 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); _________________________________________________________________

« previous php.windows (#19020) next »