Turn register_globals on for just one app
-
28-10-2019 - |
Question
We've got a client application that relies on register_globals turned on to work, but we're hosting it on a our shared server, and don't want to turn register_globals on in our main php.ini file.
I tried inserting ini_set ( 'register_globals' , 'On' );
but it didn't work. Why didn't it? And is there a better way?
Solution
You could always try to put:
extract($_REQUEST,EXTR_SKIP); //thanks @Wayne Whitty
on top of every files. It would yeld the same results as far as I know. But really, REALLY, its bad bad bad to use these. I'd look for a way to change the code. But sometimes you have no choice.
OTHER TIPS
From the php documentation:
Please note that register_globals cannot be set at runtime (ini_set()). Although, you can use .htaccess if your host allows it as described above. An example .htaccess entry: php_flag register_globals off.
register_globals could be set only in php.ini. Not runtime by ini_set You can only read this setting by follow code:
ini_get('register_globals');