LX7 LX7 - 3 months ago 9x
PHP Question

Enable register_globals in PHP 5.4

I am working on a framework that uses

. 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.


You can emulate register_globals by using extract in global scope:


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