Sometimes you need to change the way php.ini is configured. But if you are on a shared host, there will be no possibilities to get them to change, because that affects all their sites.

But of course there are ways to handle this for you any way :-)

Somethings can be changed from php, but I found one thing that I needed today and that is turn off magic_quotes_gpc which is really stupid to have on.

It adds slashes to $_GET and $_POST etc, to “secure” the user input. This is bad, because you never know if the next host have the same configuration. So handle this on your own.

To turn off this you can create a .htaccess file in your web root with this ifnormation:

php_flag magic_quotes_gpc off

Another thing that you should turn of if you haven’t already done it is “Register globals“. Sure you can do it with php.ini if you have access to it, but probably you need to do it just like we did with .htaccess again. The directive to turn off register globals, which you NEED to do is:

php_flag register_globals off

Pretty simple right :-)
Both these things help you make better code and safer products, so go ahead and start using this directly!

Similar Posts: