bookmark_borderHow to change the PHP configuration in 3 ways

PHP has ability to change the configuration setting by using ini_set function, well that’s good to hear. But why it’s need to change the default setting on the fly.

If you want to change the variable value for some purpose instead of disturbing php.ini, here is the option you can go with ini_set in PHP and php_value in htaccess.

If your website is hosted in shared hosting it will be helpful to change instead of changing in php.ini file. Most of shared hosting not allowed to change variable value in php.ini file.

1) ini_set : sets variable value on the fly by using ini_set function, but it won’t change all variable value in php.ini or hosting. It will applicable only for current php or config file which was include.

//variable newvalue
//display the variable new value
echo ini_get("");

2) php_value : sets variable value in htaccess file, which will set the variable value in folder and sub folders not for full hosting.

.htaccess file

php_value yoursessionname

3) php.ini : If you are using dedicated hosting you can change the variable value in php.ini file. It will applicable for the hosting.