<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>How to change configuration settings</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="configuration.changes.modes.html">Where a configuration setting may be set</a></div> <div class="next" style="text-align: right; float: right;"><a href="langref.html">Language Reference</a></div> <div class="up"><a href="configuration.html">Runtime Configuration</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="configuration.changes" class="sect1"> <h2 class="title">How to change configuration settings</h2> <div class="sect2" id="configuration.changes.apache"> <h3 class="title">Running PHP as an Apache module</h3> <p class="simpara"> When using PHP as an Apache module, you can also change the configuration settings using directives in Apache configuration files (e.g. <var class="filename">httpd.conf</var>) and <var class="filename">.htaccess</var> files. You will need "AllowOverride Options" or "AllowOverride All" privileges to do so. </p> <p class="para"> There are several Apache directives that allow you to change the PHP configuration from within the Apache configuration files. For a listing of which directives are <strong><code>PHP_INI_ALL</code></strong>, <strong><code>PHP_INI_PERDIR</code></strong>, or <strong><code>PHP_INI_SYSTEM</code></strong>, have a look at the <a href="ini.list.html" class="link">List of php.ini directives</a> appendix. </p> <p class="para"> <dl> <dt> <span class="term"> <code class="systemitem systemitem">php_value</code> <em><code class="parameter">name</code></em> <em><code class="parameter">value</code></em> </span> <dd> <p class="para"> Sets the value of the specified directive. Can be used only with <strong><code>PHP_INI_ALL</code></strong> and <strong><code>PHP_INI_PERDIR</code></strong> type directives. To clear a previously set value use <em>none</em> as the value. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara"> Don't use <code class="systemitem systemitem">php_value</code> to set boolean values. <code class="systemitem systemitem">php_flag</code> (see below) should be used instead. </span> </p></blockquote> </dd> </dt> <dt> <span class="term"> <code class="systemitem systemitem">php_flag</code> <em><code class="parameter">name</code></em> <em><code class="parameter">on|off</code></em> </span> <dd> <p class="para"> Used to set a boolean configuration directive. Can be used only with <strong><code>PHP_INI_ALL</code></strong> and <strong><code>PHP_INI_PERDIR</code></strong> type directives. </p> </dd> </dt> <dt> <span class="term"> <code class="systemitem systemitem">php_admin_value</code> <em><code class="parameter">name</code></em> <em><code class="parameter">value</code></em> </span> <dd> <p class="para"> Sets the value of the specified directive. This <em class="emphasis">can not be used</em> in <var class="filename">.htaccess</var> files. Any directive type set with <code class="systemitem systemitem">php_admin_value</code> can not be overridden by <var class="filename">.htaccess</var> or <span class="function"><a href="function.ini-set.html" class="function">ini_set()</a></span>. To clear a previously set value use <em>none</em> as the value. </p> </dd> </dt> <dt> <span class="term"> <code class="systemitem systemitem">php_admin_flag</code> <em><code class="parameter">name</code></em> <em><code class="parameter">on|off</code></em> </span> <dd> <p class="para"> Used to set a boolean configuration directive. This <em class="emphasis">can not be used</em> in <var class="filename">.htaccess</var> files. Any directive type set with <code class="systemitem systemitem">php_admin_flag</code> can not be overridden by <var class="filename">.htaccess</var> or <span class="function"><a href="function.ini-set.html" class="function">ini_set()</a></span>. </p> </dd> </dt> </dl> </p> <p class="para"> <div class="example" id="example-65"> <p><strong>Example #1 Apache configuration example</strong></p> <div class="example-contents"> <div class="inicode"><pre class="inicode"><IfModule mod_php5.c> php_value include_path ".:/usr/local/lib/php" php_admin_flag engine on </IfModule> <IfModule mod_php4.c> php_value include_path ".:/usr/local/lib/php" php_admin_flag engine on </IfModule></pre> </div> </div> </div> </p> <div class="caution"><strong class="caution">Caution</strong> <p class="para"> PHP constants do not exist outside of PHP. For example, in <var class="filename">httpd.conf</var> you can not use PHP constants such as <strong><code>E_ALL</code></strong> or <strong><code>E_NOTICE</code></strong> to set the <a href="errorfunc.configuration.html#ini.error-reporting" class="link">error_reporting</a> directive as they will have no meaning and will evaluate to <em class="emphasis">0</em>. Use the associated bitmask values instead. These constants can be used in <var class="filename">php.ini</var> </p> </div> </div> <div class="sect2" id="configuration.changes.windows"> <h3 class="title">Changing PHP configuration via the Windows registry</h3> <p class="simpara"> When running PHP on Windows, the configuration values can be modified on a per-directory basis using the Windows registry. The configuration values are stored in the registry key <em>HKLM\SOFTWARE\PHP\Per Directory Values</em>, in the sub-keys corresponding to the path names. For example, configuration values for the directory <em>c:\inetpub\wwwroot</em> would be stored in the key <em>HKLM\SOFTWARE\PHP\Per Directory Values\c\inetpub\wwwroot</em>. The settings for the directory would be active for any script running from this directory or any subdirectory of it. The values under the key should have the name of the PHP configuration directive and the string value. PHP constants in the values are not parsed. However, only configuration values changeable in <strong><code>PHP_INI_USER</code></strong> can be set this way, <strong><code>PHP_INI_PERDIR</code></strong> values can not. </p> </div> <div class="sect2" id="configuration.changes.other"> <h3 class="title">Other interfaces to PHP</h3> <p class="para"> Regardless of how you run PHP, you can change certain values at runtime of your scripts through <span class="function"><a href="function.ini-set.html" class="function">ini_set()</a></span>. See the documentation on the <span class="function"><a href="function.ini-set.html" class="function">ini_set()</a></span> page for more information. </p> <p class="para"> If you are interested in a complete list of configuration settings on your system with their current values, you can execute the <span class="function"><a href="function.phpinfo.html" class="function">phpinfo()</a></span> function, and review the resulting page. You can also access the values of individual configuration directives at runtime using <span class="function"><a href="function.ini-get.html" class="function">ini_get()</a></span> or <span class="function"><a href="function.get-cfg-var.html" class="function">get_cfg_var()</a></span>. </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="configuration.changes.modes.html">Where a configuration setting may be set</a></div> <div class="next" style="text-align: right; float: right;"><a href="langref.html">Language Reference</a></div> <div class="up"><a href="configuration.html">Runtime Configuration</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>