<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = 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 => 'it',
  ),
  'this' => 
  array (
    0 => 'configuration.file.php',
    1 => 'The configuration file',
    2 => 'The configuration file',
  ),
  'up' => 
  array (
    0 => 'configuration.php',
    1 => 'Runtime Configuration',
  ),
  'prev' => 
  array (
    0 => 'configuration.php',
    1 => 'Runtime Configuration',
  ),
  'next' => 
  array (
    0 => 'configuration.file.per-user.php',
    1 => '.user.ini files',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'install/ini.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="configuration.file" class="sect1">
  <h2 class="title">The configuration file</h2>

  <p class="simpara">
   The configuration file (<var class="filename">php.ini</var>)
   is read when PHP starts up. For the server module versions of PHP,
   this happens only once when the web server is started. For the
   <abbr title="Common Gateway Interface">CGI</abbr> and <abbr title="Command Line Interpreter/Interface">CLI</abbr> versions, it happens on
   every invocation.
  </p>
  <p class="para">
   <var class="filename">php.ini</var> is searched for in these locations (in order):
   <ul class="itemizedlist">
    <li class="listitem">
     <span class="simpara">
      SAPI module specific location (<code class="literal">PHPIniDir</code> directive
      in Apache 2, <code class="literal">-c</code> command line option in CGI and CLI)
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      The <var class="varname">PHPRC</var> environment variable.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      The location of the <code class="literal">php.ini</code> file
      can be set for different versions of PHP. The root of the registry keys depends on 32- or 64-bitness of the installed OS and PHP.
      For 32-bit PHP on a 32-bit OS or a 64-bit PHP on a 64-bit OS use <code class="literal">[(HKEY_LOCAL_MACHINE\SOFTWARE\PHP]</code> for 32-bit version of PHP on a 64-bit OS use <code class="literal">[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\PHP]</code>] instead.
      For same bitness installation the following registry keys
      are examined in order:
      <code class="literal">[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z]</code>,
      <code class="literal">[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y]</code> and
      <code class="literal">[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x]</code>, where
      x, y and z mean the PHP major, minor and release versions.
      For 32 bit versions of PHP on a 64 bit OS the following registry keys are examined in order:
      <code class="literal">[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6421Node\PHP\x.y.z]</code>,
      <code class="literal">[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6421Node\PHP\x.y]</code> and
      <code class="literal">[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6421Node\PHP\x]</code>, where
      x, y and z mean the PHP major, minor and release versions.
      If there is a
      value for <code class="literal">IniFilePath</code> in any of these keys, the first
      one found will be used as the location of the <code class="literal">php.ini</code>
      (Windows only).
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      <code class="literal">[HKEY_LOCAL_MACHINE\SOFTWARE\PHP]</code> or
      <code class="literal">[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\PHP]</code>, value of
      <code class="literal">IniFilePath</code> (Windows only).
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      Current working directory (except CLI).
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      The web server&#039;s directory (for SAPI modules), or directory of PHP
      (otherwise in Windows).
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      Windows directory (<var class="filename">C:\windows</var>
      or <var class="filename">C:\winnt</var>) (for Windows), or
      <code class="literal">--with-config-file-path</code> compile time option.
     </span>
    </li>
   </ul>
  </p>
  <p class="para">
   If <var class="filename">php-SAPI.ini</var> exists (where SAPI is the SAPI in use,
   so, for example, <var class="filename">php-cli.ini</var> or
   <var class="filename">php-apache.ini</var>), it is used instead of <var class="filename">php.ini</var>.
   The SAPI name can be determined with <span class="function"><a href="function.php-sapi-name.php" class="function">php_sapi_name()</a></span>.
  </p>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    The Apache web server changes the directory to root at startup, causing
    PHP to attempt to read <var class="filename">php.ini</var> from the root filesystem if it exists.
   </p>
  </p></blockquote>
  <p class="simpara">
   Environment variables can be referenced within configuration values
   in <var class="filename">php.ini</var> as shown below. As of PHP 8.3.0, a fallback value can
   be specified that will be used when the referenced variable is not
   defined.
  </p>
  <div class="example" id="example-1">
   <p><strong>Example #1 <var class="filename">php.ini</var> Environment Variables</strong></p>
    <div class="example-contents">
<div class="inicode"><pre class="inicode">; PHP_MEMORY_LIMIT is taken from environment
memory_limit = ${PHP_MEMORY_LIMIT}
; If PHP_MAX_EXECUTION_TIME is not defined, it will fall back to 30
max_execution_time = ${PHP_MAX_EXECUTION_TIME:-30}</pre>
</div>
   </div>

  </div>
  <p class="para">
   The <var class="filename">php.ini</var> directives handled by extensions are documented
   on the respective pages of the extensions themselves. A <a href="ini.php" class="link">list of
   the core directives</a> is available in the appendix. Not all
   PHP directives are necessarily documented in this manual: for a complete list
   of directives available in your PHP version, please read your well commented
   <var class="filename">php.ini</var> file. Alternatively, you may find
   <a href="https://github.com/php/php-src/blob/master/php.ini-production" class="link external">&raquo;&nbsp;the latest <var class="filename">php.ini</var></a> from Git
   helpful too.
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Example #2 <var class="filename">php.ini</var> example</strong></p>
    <div class="example-contents">
<div class="inicode"><pre class="inicode">; any text on a line after an unquoted semicolon (;) is ignored
[php] ; section markers (text within square brackets) are also ignored
; Boolean values can be set to either:
;    true, on, yes
; or false, off, no, none
register_globals = off
track_errors = yes

; you can enclose strings in double-quotes
include_path = &quot;.:/usr/local/lib/php&quot;

; backslashes are treated the same as any other character
include_path = &quot;.;c:\php\lib&quot;</pre>
</div>
    </div>

    
   </div>
  </p>
  <p class="para">
   It is possible to refer to existing .ini variables from
   within .ini files. Example: <code class="literal">open_basedir = ${open_basedir}
   &quot;:/new/dir&quot;</code>.
  </p>
  <div class="sect2" id="configuration.file.scan">
   <h3 class="title">Scan directories</h3>

   <p class="para">
    It is possible to configure PHP to scan for .ini files in a directory
    after reading <var class="filename">php.ini</var>. This can be done at compile time by setting the
    <strong class="option configure">--with-config-file-scan-dir</strong> option.
    The scan directory can then be overridden at run time
    by setting the <var class="varname">PHP_INI_SCAN_DIR</var> environment variable.
   </p>

   <p class="para">
    It is possible to scan multiple directories by separating them with the
    platform-specific path separator (<code class="literal">;</code> on Windows, NetWare
    and RISC OS; <code class="literal">:</code> on all other platforms; the value PHP is
    using is available as the <strong><code><a href="dir.constants.php#constant.path-separator">PATH_SEPARATOR</a></code></strong> constant).
    If a blank directory is given in <var class="varname">PHP_INI_SCAN_DIR</var>, PHP
    will also scan the directory given at compile time via
    <strong class="option configure">--with-config-file-scan-dir</strong>.
   </p>

   <p class="para">
    Within each directory, PHP will scan all files ending in
    <code class="literal">.ini</code> in alphabetical order. A list of the files that
    were loaded, and in what order, is available by calling
    <span class="function"><a href="function.php-ini-scanned-files.php" class="function">php_ini_scanned_files()</a></span>, or by running PHP with the
    <strong class="option unknown">--ini</strong> option.
   </p>

   <div class="informalexample">
    <div class="example-contents screen">
<div class="cdata"><pre>
Assuming PHP is configured with --with-config-file-scan-dir=/etc/php.d,
and that the path separator is :...

$ php
  PHP will load all files in /etc/php.d/*.ini as configuration files.

$ PHP_INI_SCAN_DIR=/usr/local/etc/php.d php
  PHP will load all files in /usr/local/etc/php.d/*.ini as
  configuration files.

$ PHP_INI_SCAN_DIR=:/usr/local/etc/php.d php
  PHP will load all files in /etc/php.d/*.ini, then
  /usr/local/etc/php.d/*.ini as configuration files.

$ PHP_INI_SCAN_DIR=/usr/local/etc/php.d: php
  PHP will load all files in /usr/local/etc/php.d/*.ini, then
  /etc/php.d/*.ini as configuration files.
</pre></div>
    </div>
   </div>
  </div>
 </div><?php manual_footer($setup); ?>