Function to emulate the register_globals setting in PHPWhile we all appreciate the many helpful posts to get rid of register_globals, maybe you're one of those who just loves it. More likely, your boss says you just have to live with it because he thinks it's a great feature.
No problem, just call (below defined):
<?php register_globals(); ?>
anywhere, as often as you want. Or update your scripts!
<?php function register_globals($order = 'egpcs') { if(!function_exists('register_global_array')) { function register_global_array(array $superglobal) { foreach($superglobal as $varname => $value) { global $$varname; $$varname = $value; } } } $order = explode("\r\n", trim(chunk_split($order, 1))); foreach($order as $k) { switch(strtolower($k)) { case 'e': register_global_array($_ENV); break; case 'g': register_global_array($_GET); break; case 'p': register_global_array($_POST); break; case 'c': register_global_array($_COOKIE); break; case 's': register_global_array($_SERVER); break; } } } ?>
Posted by admin
on August 20 2008 08:37:43
| 5695 Reads ·
|
|