There might be situation where you need to change php configuration values when you work on server. In local apache server, you can easily change the php configuration values using php.ini file from directory. But what will you do as php.ini is not visible on server ? The solution is.htaccess which is visible on server(.htaccess invisible ?). Using .htaccess you can change the php configuration values.
About php.ini file : The configuration file (php.ini) is read when PHP starts up. For the server module versions of PHP, this happens only once when the web server is started.
Look at below syntax for changing PHP Configuration values of php.ini using .htaccess.
php_value name value
Sets the value of the specified directive. Can be used only with PHP_INI_ALL and PHP_INI_PERDIR type directives. To clear a previously set value use none as the value.
php_flag name on|off
Used to set a boolean configuration directive. Can be used only with PHP_INI_ALL and PHP_INI_PERDIR type directives.
php_flag is used when you need to set boolean values. Other than booloean values, if you need to set php configuration value than usephp_value.
Look at below examples how to set/change upload_max_filesize , post_max_size and memory_limit using php_value in .htaccess.
php_value post_max_size 8M
php_value memory_limit 32M
If you want to increase the uploading maximum size of file than use upload_max_filesize and set to the value as per your neees.
If you want to increase maximum post size of html form than use post_max_size and set value as per your needs.
If you want to increase memory limit than use memory_limit and set value as per your needs.
Look at below examples how to set/change display_errors , log_errors and magic_quotes_gpc using php_flag in .htaccess. For this you need to change values on/off which is boolean.
php_flag log_errors On
php_flag magic_quotes_gpc off
You can enable/disable errors using display_errors. Set value to Off to make it disable.Set value to On to make it enable.
You can enable/disable Log errors using log_errors. Set value to Off to make it disable.Set value to On to make it enable.
You can enable/disable magic quotes using magic_quotes_gpc. Set value to Off to make it disable.Set value to On to make it enable.