LX7 LX7 - 5 months ago 28
PHP Question

Enable register_globals in PHP 5.4

I am working on a framework that uses

register_globals
. My local php version is 5.4. I know register_globals is DEPRECATED since
PHP 5.3.0
and REMOVED in
PHP 5.4
. But i have to make it work on
PHP 5.4
, Is there any way? Any help and suggestions will be highly appreciable. Thanks.

Answer

You can emulate register_globals by using extract in global scope:

extract($_REQUEST);

Or put it to independent function using global and variable variables

function globaling()
    {
    foreach ($_REQUEST as $key => $val)
        {
        global ${$key};
        ${$key} = $val;
        }
    }

P.S. i think that your have released application and do not want to change anything in it.

You can create globals.php file with

Then add auto_prepend_file directive to .htaccess

php_value auto_prepend_file ./globals.php

After this globals will be prepend to every call