简体   繁体   中英

Turn register_globals on for just one app

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?

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.

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.

link to php documentation on register_globals

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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM