Override a setting made in the ini file with ini_set() at run time. Not all options can be changed during run time however (see the manual for details) and some values that can be set may not have the desired effect.

What I mean by that last statement can be seen in the case of display_errors. If there is a parse error for example, your ini_set() will never been seen. Whether or not that error will be displayed depends on the ini file setting of display_errors, not what you put in ini_set().

// display the errors for this file
ini_set ("display_errors", "1");
 
// add an include path for this file
// appends a path to the current value by using ini_get()
ini_set("include_path", ini_get("'include_path") . ":/path/to/new/includes");

For those running Apache with .htaccess available, you can perform a similar function in the .htaccess file with php_flag. This can be useful if you don’t have permissions to change settings on a server level (php.ini or httpd.conf). For example, it is useless to change the register_globals value in the php script since php has already performed that by the time the script starts.

In the .htaccess file use php_value to set a configuration option, but use php_flag to set boolean values.

php_value default_socket_timeout 120
php_flag register_globals Off