If you require register_globals = on yet your host has it off, you should instead set it to on in .htaccess as opposed of hacking the behavior. And this sorta hack should NEVER be used for new code.
And this isn't a "fix for certain PHP versions" but rather it's a hack to sorta mimick the register_globals directive being on. register_globals is off by default as of PHP 4.2.0 but that's just a default. It can be on or off in any PHP 4+ version (it's always on in PHP 3) and in order to maintain backwards compatability for their clients, many hosts change this new default value since PHP 4.2.0 to be back on.
Here's another way to sorta mimick register_globals = on by polluting a script with tons of mostly unused variables:
// Do this ONLY if you must, never for new code!
if (!ini_get('register_globals')) {
$types_to_register = array('GET','POST','COOKIE','SESSION','SERVER');
foreach ($types_to_register as $type) {
if (@count(${'HTTP_' . $type . '_VARS'}) > 0) {
extract(${'HTTP_' . $type . '_VARS'}, EXTR_OVERWRITE);
}
}
}
Back to .htaccess. If your host allows use of .htaccess then create (or modify) this file in your appropriate web directory with this line:
php_value register_globals 1
If you wonder what all this hoopla is about, and what the big deal is about register_globals, then read this manual page:
http://www.php.net/security.registerglobals
And to learn alternative (and preferred) ways for using external variables, read this:
http://www.php.net/variables.external