<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/features.commandline.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'features.commandline.options.php',
    1 => 'Options',
    2 => 'Command line options',
  ),
  'up' => 
  array (
    0 => 'features.commandline.php',
    1 => 'Command line usage',
  ),
  'prev' => 
  array (
    0 => 'features.commandline.differences.php',
    1 => 'Differences to other SAPIs',
  ),
  'next' => 
  array (
    0 => 'features.commandline.usage.php',
    1 => 'Usage',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'features/commandline.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="features.commandline.options" class="section">
  <h2 class="title">Command line options</h2>
  
  
  <p class="para">
   The list of command line options provided by the PHP binary can be queried
   at any time by running PHP with the <strong class="option unknown">-h</strong> switch:
   <div class="example-contents screen">
<div class="cdata"><pre>
Usage: php [options] [-f] &lt;file&gt; [--] [args...]
   php [options] -r &lt;code&gt; [--] [args...]
   php [options] [-B &lt;begin_code&gt;] -R &lt;code&gt; [-E &lt;end_code&gt;] [--] [args...]
   php [options] [-B &lt;begin_code&gt;] -F &lt;file&gt; [-E &lt;end_code&gt;] [--] [args...]
   php [options] -- [args...]
   php [options] -a

  -a               Run interactively
  -c &lt;path&gt;|&lt;file&gt; Look for php.ini file in this directory
  -n               No php.ini file will be used
  -d foo[=bar]     Define INI entry foo with value &#039;bar&#039;
  -e               Generate extended information for debugger/profiler
  -f &lt;file&gt;        Parse and execute &lt;file&gt;.
  -h               This help
  -i               PHP information
  -l               Syntax check only (lint)
  -m               Show compiled in modules
  -r &lt;code&gt;        Run PHP &lt;code&gt; without using script tags &lt;?..?&gt;
  -B &lt;begin_code&gt;  Run PHP &lt;begin_code&gt; before processing input lines
  -R &lt;code&gt;        Run PHP &lt;code&gt; for every input line
  -F &lt;file&gt;        Parse and execute &lt;file&gt; for every input line
  -E &lt;end_code&gt;    Run PHP &lt;end_code&gt; after processing all input lines
  -H               Hide any passed arguments from external tools.
  -S &lt;addr&gt;:&lt;port&gt; Run with built-in web server.
  -t &lt;docroot&gt;     Specify document root &lt;docroot&gt; for built-in web server.
  -s               Output HTML syntax highlighted source.
  -v               Version number
  -w               Output source with stripped comments and whitespace.
  -z &lt;file&gt;        Load Zend extension &lt;file&gt;.

  args...          Arguments passed to script. Use -- args when first argument
                   starts with - or script is read from stdin

  --ini            Show configuration file names

  --rf &lt;name&gt;      Show information about function &lt;name&gt;.
  --rc &lt;name&gt;      Show information about class &lt;name&gt;.
  --re &lt;name&gt;      Show information about extension &lt;name&gt;.
  --rz &lt;name&gt;      Show information about Zend extension &lt;name&gt;.
  --ri &lt;name&gt;      Show configuration for extension &lt;name&gt;.
</pre></div>
   </div>
  </p>
  
  <p class="para">
   <table class="doctable table">
    <caption><strong>Command line options</strong></caption>
    
     <thead>
      <tr>
       <th>Option</th>
       <th>Long Option</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>-a</td>
       <td>--interactive</td>
       <td>
        <p class="para">
         Run PHP interactively. For more information, see the <a href="features.commandline.interactive.php" class="link">Interactive shell</a>
         section.
        </p>
       </td>
      </tr>

      <tr>
       <td>-b</td>
       <td>--bindpath</td>
       <td>
        <p class="para">
         Bind Path for external FASTCGI Server mode (<abbr title="Common Gateway Interface">CGI</abbr>
         only).
        </p>
       </td>
      </tr>

      <tr>
       <td>-C</td>
       <td>--no-chdir</td>
       <td>
        <p class="para">
         Do not chdir to the script&#039;s directory (<abbr title="Common Gateway Interface">CGI</abbr> only).
        </p>
       </td>
      </tr>

      <tr>
       <td>-q</td>
       <td>--no-header</td>
       <td>
        <p class="para">
         Quiet-mode. Suppress <abbr title="Hypertext Transfer Protocol">HTTP</abbr> header output
         (<abbr title="Common Gateway Interface">CGI</abbr> only).
        </p>
       </td>
      </tr>

      <tr>
       <td>-T</td>
       <td>--timing</td>
       <td>
        <p class="para">
         Measure execution time of script repeated <var class="varname">count</var>
         times (<abbr title="Common Gateway Interface">CGI</abbr> only).
        </p>
       </td>
      </tr>

      <tr>
       <td>-c</td>
       <td>--php-ini</td>
       <td>
        <p class="para">
         Specifies either a directory in which to look for
         <var class="filename">php.ini</var>, or a custom <code class="literal">INI</code> file
         (which does not need to be named <var class="filename">php.ini</var>), e.g.:
        </p>
        <p class="para"><div class="informalexample">
         <div class="example-contents screen">
<div class="cdata"><pre>
$ php -c /custom/directory/ my_script.php

$ php -c /custom/directory/custom-file.ini my_script.php
</pre></div>
         </div>
        </div></p>
        <p class="para">
         If this option is not specified, <var class="filename">php.ini</var> is searched for in the
         <a href="configuration.file.php" class="link">default locations</a>.
        </p>
       </td>
      </tr>

      <tr>
       <td>-n</td>
       <td>--no-php-ini</td>
       <td>
        <p class="para">
         Ignore <var class="filename">php.ini</var> completely.
        </p>
       </td>
      </tr>

      <tr>
       <td>-d</td>
       <td>--define</td>
       <td>
        <p class="para">
         Set a custom value for any of the configuration
         directives allowed in <var class="filename">php.ini</var>. The syntax is:
         <div class="example-contents screen">
 <div class="cdata"><pre>
 -d configuration_directive[=value]
 </pre></div>
         </div>
        </p>
        <p class="para"><div class="example" id="example-1">
         <p><strong>Приклад #1 Example of using <code class="literal">-d</code> to set an INI setting</strong></p>
         <div class="example-contents screen">
<div class="cdata"><pre>
# Omitting the value part will set the given configuration directive to &quot;1&quot;
$ php -d max_execution_time
        -r &#039;$foo = ini_get(&quot;max_execution_time&quot;); var_dump($foo);&#039;
string(1) &quot;1&quot;

# Passing an empty value part will set the configuration directive to &quot;&quot;
php -d max_execution_time=
        -r &#039;$foo = ini_get(&quot;max_execution_time&quot;); var_dump($foo);&#039;
string(0) &quot;&quot;

# The configuration directive will be set to anything passed after the &#039;=&#039; character
$  php -d max_execution_time=20
        -r &#039;$foo = ini_get(&quot;max_execution_time&quot;); var_dump($foo);&#039;
string(2) &quot;20&quot;
$  php
        -d max_execution_time=doesntmakesense
        -r &#039;$foo = ini_get(&quot;max_execution_time&quot;); var_dump($foo);&#039;
string(15) &quot;doesntmakesense&quot;
</pre></div>
         </div>
        </div></p>
       </td>
      </tr>

      <tr>
       <td>-e</td>
       <td>--profile-info</td>
       <td>
        <p class="para">
         Activate the extended information mode, to be used by a
         debugger/profiler.
        </p>
       </td>
      </tr>

      <tr>
       <td>-f</td>
       <td>--file</td>
       <td>
        <p class="para">
         Parse and execute the specified file. The
         <strong class="option unknown">-f</strong> is optional and may be omitted - providing just
         the filename to execute is sufficient.
        </p>
       </td>
      </tr>

      <tr>
       <td>-h and -?</td>
       <td>--help and --usage</td>
       <td>
        Output a list of
        command line options with one line descriptions of what they do.
       </td>
      </tr>

      <tr>
       <td>-i</td>
       <td>--info</td>
       <td>
        Calls <span class="function"><a href="function.phpinfo.php" class="function">phpinfo()</a></span>, and prints out the results.
        If PHP is not working correctly, it is advisable to use the command
        <strong class="command">php -i</strong> and see whether any error
        messages are printed out before or in place of the information tables.
        Beware that when using the <abbr title="Common Gateway Interface">CGI</abbr> mode the output is in
        <abbr title="Hyper Text Markup Language">HTML</abbr> and therefore very large.
       </td>
      </tr>

      <tr>
       <td>-l</td>
       <td>--syntax-check</td>
       <td>
        <p class="para">
         Syntax check but do not execute the given PHP code.
         The input from standard input will be processed if no filenames are specified,
         otherwise each filename will be checked.
         On success, the text
         <code class="literal">No syntax errors detected in &lt;filename&gt;</code> is
         written to standard output.
         On failure, the text <code class="literal">Errors parsing &lt;filename&gt;</code>
         is written to standard output in addition to the internal parser error.
         If any failures are found in the specified files (or standard input),
         the shell return code is set to <code class="literal">-1</code>, otherwise the
         shell return code is set to <code class="literal">0</code>.
        </p>
        <p class="para">
         This option won&#039;t find fatal errors (like undefined functions) that
         require executing the code.
        </p>
        <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
         <p class="para">
          Prior to PHP 8.3.0, it was only possible to specify one filename to
          be checked.
         </p>
        </p></blockquote>
        <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
         <p class="para">
          This option does not work together with the <strong class="option unknown">-r</strong>
          option.
         </p>
        </p></blockquote>
       </td>
      </tr>

      <tr>
       <td>-m</td>
       <td>--modules</td>
       <td>
        <p class="para"><div class="example" id="example-2">
         <p><strong>Приклад #2 Printing built in (and loaded) PHP and Zend modules</strong></p>
         <div class="example-contents screen">
<div class="cdata"><pre>
$ php -m
[PHP Modules]
xml
tokenizer
standard
session
posix
pcre
overload
mysql
mbstring
ctype

[Zend Modules]
</pre></div>
         </div>
        </div></p>
       </td>
      </tr>

      <tr>
       <td>-r</td>
       <td>--run</td>
       <td>
        <p class="para">
         Allows execution of PHP included directly on the command line.
         The PHP start and end tags (<code class="literal">&lt;?php</code> and
         <code class="literal">?&gt;</code>) are <strong>not
         needed</strong> and will cause a parse error if present.
        </p>
        <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
         <p class="para">
          Care must be taken when using this form of PHP not
          to collide with command line variable substitution done by the
          shell.
         </p>
         <div class="example" id="example-3">
          <p><strong>Приклад #3 Getting a syntax error when using double quotes</strong></p>
          <div class="example-contents screen">
<div class="cdata"><pre>
$ php -r &quot;$foo = get_defined_constants();&quot;
PHP Parse error:  syntax error, unexpected &#039;=&#039; in Command line code on line 1

Parse error: syntax error, unexpected &#039;=&#039; in Command line code on line 1
</pre></div>
          </div>
         </div>
         <p class="para">
          The problem here is that sh/bash performs variable substitution
          even when using double quotes <code class="literal">&quot;</code>. Since the
          variable <var class="varname">$foo</var> is unlikely to be defined, it
          expands to nothing which results in the code passed to
          PHP for execution actually reading:
         </p>
         <div class="informalexample">
          <div class="example-contents screen">
<div class="cdata"><pre>
$ php -r &quot; = get_defined_constants();&quot;
</pre></div>
          </div>
         </div>
         
         <p class="para">
          The correct way would be to use single quotes <code class="literal">&#039;</code>.
          Variables in single-quoted strings are not expanded
          by sh/bash.
         </p>
         <div class="example" id="example-4">
          <p><strong>Приклад #4 Using single quotes to prevent the shell&#039;s variable
          substitution</strong></p>
          <div class="example-contents screen">
<div class="cdata"><pre>
$ php -r &#039;$foo = get_defined_constants(); var_dump($foo);&#039;
array(370) {
  [&quot;E_ERROR&quot;]=&gt;
  int(1)
  [&quot;E_WARNING&quot;]=&gt;
  int(2)
  [&quot;E_PARSE&quot;]=&gt;
  int(4)
  [&quot;E_NOTICE&quot;]=&gt;
  int(8)
  [&quot;E_CORE_ERROR&quot;]=&gt;
  [...]
</pre></div>
          </div>
         </div>
         <p class="para">
          If using a shell other than sh/bash, further issues might be
          experienced - if appropriate, a bug report should be opened at
          <a href="https://github.com/php/php-src/issues" class="link external">&raquo;&nbsp;https://github.com/php/php-src/issues</a>.
          It is still easy to run into trouble when trying to use variables
          (shell or PHP) in command-line code, or using backslashes for
          escaping, so take great care when doing so. You have been warned!
         </p>
        </p></blockquote>
        <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
         <p class="para">
          <strong class="option unknown">-r</strong> is available in the <abbr title="Command Line Interpreter/Interface">CLI</abbr> <abbr title="Server Application Programming Interface">SAPI</abbr>, but not in the
          <em>CGI</em> <abbr title="Server Application Programming Interface">SAPI</abbr>.
         </p>
        </p></blockquote>
        <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
         <p class="para">
          This option is only intended for very basic code, so some
          configuration directives (such as <a href="ini.core.php#ini.auto-prepend-file" class="link">auto_prepend_file</a> and <a href="ini.core.php#ini.auto-append-file" class="link">auto_append_file</a>) are ignored
          in this mode.
         </p>
        </p></blockquote>
       </td>
      </tr>

      <tr>
       <td>-B</td>
       <td>--process-begin</td>
       <td>
        <p class="para">
         PHP code to execute before processing stdin.
        </p>
       </td>
      </tr>

      <tr>
       <td>-R</td>
       <td>--process-code</td>
       <td>
        <p class="para">
         PHP code to execute for every input line.
        </p>
        <p class="para">
         There are two special variables available in this mode:
         <var class="varname">$argn</var> and <var class="varname">$argi</var>.
         <var class="varname">$argn</var> will contain the line PHP is processing at
         that moment, while <var class="varname">$argi</var> will contain the line
         number.
        </p>
       </td>
      </tr>

      <tr>
       <td>-F</td>
       <td>--process-file</td>
       <td>
        <p class="para">
         PHP file to execute for every input line.
        </p>
       </td>
      </tr>

      <tr>
       <td>-E</td>
       <td>--process-end</td>
       <td>
        <p class="para">
         PHP code to execute after processing the input.
        </p>
        <p class="para"><div class="example" id="example-5">
         <p><strong>Приклад #5 Using the <strong class="option unknown">-B</strong>, <strong class="option unknown">-R</strong> and
          <strong class="option unknown">-E</strong> options to count the number of lines of a
          project.
         </strong></p>
         <div class="example-contents screen">
<div class="cdata"><pre>
$ find my_proj | php -B &#039;$l=0;&#039; -R &#039;$l += count(@file($argn));&#039; -E &#039;echo &quot;Total Lines: $l\n&quot;;&#039;
Total Lines: 37328
</pre></div>
         </div>
        </div></p>
       </td>
      </tr>

      <tr>
       <td>-S</td>
       <td>--server</td>
       <td>
        <p class="para">
         Starts <a href="features.commandline.webserver.php" class="link">built-in web
         server</a>.
        </p>
       </td>
      </tr>

      <tr>
       <td>-t</td>
       <td>--docroot</td>
       <td>
        Specifies document root for <a href="features.commandline.webserver.php" class="link">built-in web server</a>.
       </td>
      </tr>

      <tr>
       <td>-s</td>
       <td>--syntax-highlight and --syntax-highlighting</td>
       <td>
        <p class="para">
         Display colour syntax highlighted source.
        </p>
        <p class="para">
         This option uses the internal mechanism to parse the file and writes
         an HTML highlighted version of it to
         standard output. Note that all it does is generate a block of
         <code class="literal">&lt;code&gt; [...] &lt;/code&gt;</code>
         HTML tags, no HTML headers.
        </p>
        <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
         <p class="para">
          This option does not work together with the <strong class="option unknown">-r</strong>
          option.
         </p>
        </p></blockquote>
       </td>
      </tr>

      <tr>
       <td>-v</td>
       <td>--version</td>
       <td>
        <p class="para"><div class="example" id="example-6">
         <p><strong>Приклад #6 Using <strong class="option unknown">-v</strong> to get the <abbr title="Server Application Programming Interface">SAPI</abbr>
         name and the version of PHP and Zend</strong></p>
         <div class="example-contents screen">
<div class="cdata"><pre>
$ php -v
PHP 5.3.1 (cli) (built: Dec 11 2009 19:55:07)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
</pre></div>
         </div>
        </div></p>
       </td>
      </tr>

      <tr>
       <td>-w</td>
       <td>--strip</td>
       <td>
        <p class="para">
         Display source with comments and whitespace stripped.
        </p>
        <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
         <p class="para">
          This option does not work together with the <strong class="option unknown">-r</strong>
          option.
         </p>
        </p></blockquote>
       </td>
      </tr>

      <tr>
       <td>-z</td>
       <td>--zend-extension</td>
       <td>
        <p class="para">
         Load Zend extension. If only a filename is given, PHP tries to load
         this extension from the current default library path on your system
         (usually <var class="filename">/etc/ld.so.conf</var> on Linux systems, for
         example). Passing a filename with an absolute path will
         not use the system&#039;s library search path. A relative filename including
         directory information will tell PHP to try
         loading the extension relative to the current directory.
        </p>
       </td>
      </tr>

      <tr>
       <td class="empty">&nbsp;</td>
       <td>--ini</td>
       <td>
        <p class="para">
         Show configuration file names and scanned directories.
         <div class="example" id="example-7">
          <p><strong>Приклад #7 <code class="literal">--ini</code> example</strong></p>
          <div class="example-contents">
<div class="shellcode"><pre class="shellcode">$ php --ini
Configuration File (php.ini) Path: /usr/dev/php/5.2/lib
Loaded Configuration File:         /usr/dev/php/5.2/lib/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)</pre>
</div>
          </div>

         </div>
        </p>
       </td>
      </tr>

      <tr>
       <td>--rf</td>
       <td>--rfunction</td>
       <td>
        <p class="para">
         Show information about the given function or class method (e.g.
         number and name of the parameters).
        </p>
        <p class="para">
         This option is only available if PHP was compiled with
         <a href="book.reflection.php" class="link">Reflection</a> support.
        </p>
        <p class="para">
         <div class="example" id="example-8">
          <p><strong>Приклад #8 basic <code class="literal">--rf</code> usage</strong></p>
          <div class="example-contents">
<div class="shellcode"><pre class="shellcode">$ php --rf var_dump
Function [ &lt;internal&gt; public function var_dump ] {

  - Parameters [2] {
    Parameter #0 [ &lt;required&gt; $var ]
    Parameter #1 [ &lt;optional&gt; $... ]
  }
}</pre>
</div>
          </div>

         </div>
        </p>
       </td>
      </tr>

      <tr>
       <td>--rc</td>
       <td>--rclass</td>
       <td>
        <p class="para">
         Show information about the given class (list of constants, properties
         and methods).
        </p>
        <p class="para">
         This option is only available if PHP was compiled with
         <a href="book.reflection.php" class="link">Reflection</a> support.
        </p>
        <p class="para">
         <div class="example" id="example-9">
          <p><strong>Приклад #9 <code class="literal">--rc</code> example</strong></p>
          <div class="example-contents">
<div class="shellcode"><pre class="shellcode">$ php --rc Directory
Class [ &lt;internal:standard&gt; class Directory ] {

  - Constants [0] {
  }

  - Static properties [0] {
  }

  - Static methods [0] {
  }

  - Properties [0] {
  }

  - Methods [3] {
    Method [ &lt;internal&gt; public method close ] {
    }

    Method [ &lt;internal&gt; public method rewind ] {
    }

    Method [ &lt;internal&gt; public method read ] {
    }
  }
}</pre>
</div>
          </div>

         </div>
        </p>
       </td>
      </tr>

      <tr>
       <td>--re</td>
       <td>--rextension</td>
       <td>
        <p class="para">
         Show information about the given extension (list of <var class="filename">php.ini</var> options,
         defined functions, constants and classes).
        </p>
        <p class="para">
         This option is only available if PHP was compiled with
         <a href="book.reflection.php" class="link">Reflection</a> support.
        </p>
        <p class="para">
         <div class="example" id="example-10">
          <p><strong>Приклад #10 <code class="literal">--re</code> example</strong></p>
          <div class="example-contents">
<div class="shellcode"><pre class="shellcode">$ php --re json
Extension [ &lt;persistent&gt; extension #19 json version 1.2.1 ] {

  - Functions {
    Function [ &lt;internal&gt; function json_encode ] {
    }
    Function [ &lt;internal&gt; function json_decode ] {
    }
  }
}</pre>
</div>
          </div>

         </div>
        </p>
       </td>
      </tr>

      <tr>
       <td>--rz</td>
       <td>--rzendextension</td>
       <td>
        <p class="para">
         Show the configuration information for the given Zend extension (the
         same information that is returned by <span class="function"><a href="function.phpinfo.php" class="function">phpinfo()</a></span>).
        </p>
       </td>
      </tr>

      <tr>
       <td>--ri</td>
       <td>--rextinfo</td>
       <td>
        <p class="para">
         Show the configuration information for the given extension (the same
         information that is returned by <span class="function"><a href="function.phpinfo.php" class="function">phpinfo()</a></span>).
         The core configuration information
         is available using &quot;main&quot; as extension name.
        </p>
        <p class="para">
         <div class="example" id="example-11">
          <p><strong>Приклад #11 <code class="literal">--ri</code> example</strong></p>
          <div class="example-contents">
<div class="shellcode"><pre class="shellcode">$ php --ri date

date

date/time support =&gt; enabled
&quot;Olson&quot; Timezone Database Version =&gt; 2009.20
Timezone Database =&gt; internal
Default timezone =&gt; Europe/Oslo

Directive =&gt; Local Value =&gt; Master Value
date.timezone =&gt; Europe/Oslo =&gt; Europe/Oslo
date.default_latitude =&gt; 59.930972 =&gt; 59.930972
date.default_longitude =&gt; 10.776699 =&gt; 10.776699
date.sunset_zenith =&gt; 90.583333 =&gt; 90.583333
date.sunrise_zenith =&gt; 90.583333 =&gt; 90.583333</pre>
</div>
          </div>

         </div>
        </p>
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
  
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    Options <code class="literal">-rBRFEH</code>, <code class="literal">--ini</code> and
    <code class="literal">--r[fcezi]</code> are available only in <abbr title="Command Line Interpreter/Interface">CLI</abbr>.
   </p>
  </p></blockquote>
 </div><?php manual_footer($setup); ?>