PHP Automatic URL Parsing (?a=xxx -> $a)

Soldato
Joined
27 Dec 2005
Posts
17,316
Location
Bristol
Up until recently my host/site used to automatically parse URL variables. That is, I wouldn't have to use "$a = $_GET['a'];" to retrieve the variable of $a from the URL. Now, something's obviously changed and it's no longer doing that. I changed the htaccess but with nothing related to this as far as I know, so I was wondering how you enable it?
 
That links great but I can't find an obvious/conclusive way of turning them back on? Tried php_flag register_globals 1 in htaccess to no avail.
 
It's considered a security hazard to have register globals on, so if you're able to modify your code so that it doesn't require it, that's a good idea.

Placing this line in your .htaccess file should turn it back on, if the server allows php.ini to be over-ridden. If it doesn't work you may need to adjust php.ini.

php_flag register_globals off

If you're developing new code on a separate machine, it's better for code portability to have register_globals on, as it will then work on servers with either set up.
 
Yeh it's (rightly) considered a security risk, that's why it's been turned off.

php.ini contains all the config for PHP, but as mentioned, if you can't access it, the only other option is trying to set that option in .htacess.

The best option is to develop code that doesn't rely on it, however :)
 
None of the options I've tried have worked so I've had to resort to adding various GET and POST codes around my site, which is fine.

The only thing I'm annoyed about is that this has been the case for probably about a week without me knowing (forms etc not working). I just hope that I haven't missed too many customer enquiries and the like as a result.
 
Back
Top Bottom