Source of: /manual/en/configuration.changes.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/configuration.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'configuration.changes.php',
1 => 'How to change configuration settings',
),
'up' =>
array (
0 => 'configuration.php',
1 => 'Runtime Configuration',
),
'prev' =>
array (
0 => 'configuration.changes.modes.php',
1 => 'Where a configuration setting may be set',
),
'next' =>
array (
0 => 'langref.php',
1 => 'Language Reference',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="configuration.changes" class="sect1">
<h2 class="title">How to change configuration settings</h2>
<div id="configuration.changes.apache" class="sect2">
<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
<b><tt class="constant">PHP_INI_ALL</tt></b>, <b><tt class="constant">PHP_INI_PERDIR</tt></b>,
or <b><tt class="constant">PHP_INI_SYSTEM</tt></b>, have a look at the
<a href="ini.list.php" class="link">List of php.ini directives</a> appendix.
</p>
<p class="para">
</p><dl>
<dt class="varlistentry">
<span class="term">
<code class="systemitem systemitem">php_value</code>
<i><tt class="parameter">name</tt></i>
<i><tt class="parameter">value</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
Sets the value of the specified directive.
Can be used only with <b><tt class="constant">PHP_INI_ALL</tt></b> and <b><tt class="constant">PHP_INI_PERDIR</tt></b> type directives.
To clear a previously set value use <i>none</i> as the value.
</p>
<blockquote><p><b class="note">Note</b>:
<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 class="varlistentry">
<span class="term">
<code class="systemitem systemitem">php_flag</code>
<i><tt class="parameter">name</tt></i>
<i><tt class="parameter">on|off</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
Used to set a boolean configuration directive.
Can be used only with <b><tt class="constant">PHP_INI_ALL</tt></b> and
<b><tt class="constant">PHP_INI_PERDIR</tt></b> type directives.
</p>
</dd>
<dt class="varlistentry">
<span class="term">
<code class="systemitem systemitem">php_admin_value</code>
<i><tt class="parameter">name</tt></i>
<i><tt class="parameter">value</tt></i>
</span>
</dt><dd class="listitem">
<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 <a href="function.ini-set.php" class="function">ini_set()</a>.
To clear a previously set value use <i>none</i> as the value.
</p>
</dd>
<dt class="varlistentry">
<span class="term">
<code class="systemitem systemitem">php_admin_flag</code>
<i><tt class="parameter">name</tt></i>
<i><tt class="parameter">on|off</tt></i>
</span>
</dt><dd class="listitem">
<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>.
</p>
</dd>
</dl>
<p>
</p>
<p class="para">
</p><div class="example">
<p><b>Example #1 Apache configuration example</b></p>
<div class="example-contents programlisting">
<div class="inicode"><pre class="inicode"><IfModule mod_php5.c>
php_value include_path ".:/usr/local/lib/php"
php_admin_flag safe_mode on
</IfModule>
<IfModule mod_php4.c>
php_value include_path ".:/usr/local/lib/php"
php_admin_flag safe_mode on
</IfModule></pre>
</div>
</div>
</div><p>
</p>
<div class="caution"><b class="caution">Caution</b>
<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 <b><tt class="constant">E_ALL</tt></b> or <b><tt class="constant">E_NOTICE</tt></b>
to set the <a href="errorfunc.configuration.php#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 id="configuration.changes.windows" class="sect2">
<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
<i>HKLM\SOFTWARE\PHP\Per Directory Values</i>,
in the sub-keys corresponding to the path names. For example, configuration
values for the directory <i>c:\inetpub\wwwroot</i> would
be stored in the key <i>HKLM\SOFTWARE\PHP\Per Directory
Values\c\inetpub\wwwroot</i>. 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
<b><tt class="constant">PHP_INI_USER</tt></b> can be set
this way, <b><tt class="constant">PHP_INI_PERDIR</tt></b> values can not.
</p>
</div>
<div id="configuration.changes.other" class="sect2">
<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 <a href="function.ini-set.php" class="function">ini_set()</a>. See the documentation
on the <a href="function.ini-set.php" class="function">ini_set()</a> 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
<a href="function.phpinfo.php" class="function">phpinfo()</a> function, and review the resulting
page. You can also access the values of individual configuration
directives at runtime using <a href="function.ini-get.php" class="function">ini_get()</a> or
<a href="function.get-cfg-var.php" class="function">get_cfg_var()</a>.
</p>
</div>
</div><?php manual_footer(); ?>