Shared web hosting always has been and always will be a low cost way of hosting your average website. After all, most people cannot afford to rent/buy a dedicated server for their website. However, shared hosting presents a major inconvenience: customisability. Since you're "sharing" this server with other people, you can't just do what you want. Your host will decide on all server wide settings, in the interests of all. These settings will include PHP settings.
But let's say you need to change these settings: how are you going to do it? One way would be to get down on your hands and knees and plead with your host. But that's not exactly an easy or sure way of getting the PHP configuration changed. No, there's a much easier solution: set them yourself! "But they're server wide settings" I hear you say. Wrong! Most of the PHP settings which developers use can actually be changed by the user, surprisingly enough.
Now, let's get down to the technical aspect of this. Let's say I want to turn
off magic quotes (automatic escape of special characters, usually in preparation
for use in an SQL query). The relevant setting for this would be
You now have two ways of setting it to off:
This would turn off magic quotes in that particular script. Or you
could include it in your template/header file, and have it take effect in
all your PHP scripts.
ini_set ('magic_quotes_gpc', 0);
php_valuecommand. Simply place the following code in your .htaccess file:
You can place this file in different places:
php_value magic_quotes_gpc 0
Simple, eh? Now didn't that save you (and your server administrator!) a lot of trouble? For a complete list of settings which you can or cannot set by yourself, please see PHP.net: http://www.php.net/manual/en/function.ini-set.php.
© 4WebHelp and Daniel
Page URL: http://www.4webhelp.net/tutorials/php/config_override.php
Back to the "pretty" page!
© 2021, 4WebHelp Team.