Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 1889

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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>Command line options</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="features.commandline.differences.html">Differences to other SAPIs</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="features.commandline.usage.html">Usage</a></div>
 <div class="up"><a href="features.commandline.html">Command line usage</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><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.html" 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 (<acronym title="Common Gateway Interface">CGI</acronym>
         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 (<acronym title="Common Gateway Interface">CGI</acronym> only).
        </p>
       </td>
      </tr>

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

      <tr>
       <td>-T</td>
       <td>--timing</td>
       <td>
        <p class="para">
         Measure execution time of script repeated <var class="varname"><var class="varname">count</var></var>
         times (<acronym title="Common Gateway Interface">CGI</acronym> 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 <em>INI</em> 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.html" 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-364">
         <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>
        <blockquote class="note"><p><strong class="note">Note</strong>: 
         <p class="para">
          To pass arguments to a script, the first argument must be
          <em>--</em>, otherwise PHP will interpret them as PHP
          options.
         </p>
        </p></blockquote>
       </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.html" 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 <acronym title="Common Gateway Interface">CGI</acronym> mode the output is in
        <acronym title="Hyper Text Markup Language">HTML</acronym> and therefore very large.
       </td>
      </tr>

      <tr>
       <td>-l</td>
       <td>--syntax-check</td>
       <td>
        <p class="para">
         Provides a convenient way to perform only a syntax check
         on the given PHP code. On success, the text
         <em>No syntax errors detected in &lt;filename&gt;</em> is
         written to standard output and the shell return code is
         <em>0</em>. On failure, the text <em>Errors parsing
         &lt;filename&gt;</em> in addition to the internal parser error
         message is written to standard output and the shell return code is set
         to <em>-1</em>.
        </p>
        <p class="para">
         This option won&#039;t find fatal errors (like undefined functions). Use
         the <strong class="option unknown">-f</strong>
 to test for fatal errors too.
        </p>
        <blockquote class="note"><p><strong class="note">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-365">
         <p><strong>Example #1 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 (<em>&lt;?php</em> and
         <em>?&gt;</em>) are <em class="emphasis">not
         needed</em> and will cause a parse error if present.
        </p>
        <blockquote class="note"><p><strong class="note">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-366">
          <p><strong>Example #2 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 <em>&quot;</em>. Since the
          variable <var class="varname"><var class="varname">$foo</var></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 <em>&#039;</em>.
          Variables in single-quoted strings are not expanded
          by sh/bash.
         </p>
         <div class="example" id="example-367">
          <p><strong>Example #3 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="http://bugs.php.net/" class="link external">&raquo;&nbsp;http://bugs.php.net/</a>.
          It is still easy to run into trouble when trying to use variables
          (shell or PHP) in commnad-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">Note</strong>: 
         <p class="para">
          <strong class="option unknown">-r</strong>
 is available in the <acronym title="Command Line Interpreter/Interface">CLI</acronym> <acronym title="Server Application Programming Interface">SAPI</acronym>, but not in the
          <em class="emphasis">CGI</em> <acronym title="Server Application Programming Interface">SAPI</acronym>.
         </p>
        </p></blockquote>
        <blockquote class="note"><p><strong class="note">Note</strong>: 
         <p class="para">
          This option is only intended for very basic code, so some
          configuration directives (such as <a href="ini.core.html#ini.auto-prepend-file" class="link">auto_prepend_file</a> and <a href="ini.core.html#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. Added in PHP 5.
        </p>
       </td>
      </tr>

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

      <tr>
       <td>-E</td>
       <td>--process-end</td>
       <td>
        <p class="para">
         PHP code to execute after processing the input. Added in PHP 5.
        </p>
        <p class="para"><div class="example" id="example-368">
         <p><strong>Example #4 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.html" class="link">built-in web
         server</a>. Available as of PHP 5.4.0.
        </p>
       </td>
      </tr>

      <tr>
       <td>-t</td>
       <td>--docroot</td>
       <td>
        Specifies document root for <a href="features.commandline.webserver.html" class="link">built-in web server</a>.
        Available as of PHP 5.4.0.
       </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
         <em>&lt;code&gt; [...] &lt;/code&gt;</em>
         HTML tags, no HTML headers.
        </p>
        <blockquote class="note"><p><strong class="note">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-369">
         <p><strong>Example #5 Using <strong class="option unknown">-v</strong>
 to get the <acronym title="Server Application Programming Interface">SAPI</acronym>
         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">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. Available as
         of PHP 5.2.3.
         <div class="example" id="example-370">
          <p><strong>Example #6 <em>--ini</em> 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). Available as of PHP 5.1.2.
        </p>
        <p class="para">
         This option is only available if PHP was compiled with
         <a href="book.reflection.html" class="link">Reflection</a> support.
        </p>
        <p class="para">
         <div class="example" id="example-371">
          <p><strong>Example #7 basic <em>--rf</em> 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). Available as of PHP 5.1.2.
        </p>
        <p class="para">
         This option is only available if PHP was compiled with
         <a href="book.reflection.html" class="link">Reflection</a> support.
        </p>
        <p class="para">
         <div class="example" id="example-372">
          <p><strong>Example #8 <em>--rc</em> 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). Available as of PHP 5.1.2.
        </p>
        <p class="para">
         This option is only available if PHP was compiled with
         <a href="book.reflection.html" class="link">Reflection</a> support.
        </p>
        <p class="para">
         <div class="example" id="example-373">
          <p><strong>Example #9 <em>--re</em> 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.html" class="function">phpinfo()</a></span>).
         Available as of PHP 5.4.0.
        </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.html" class="function">phpinfo()</a></span>).
         Available as of PHP 5.2.2. The core configuration information
         is available using &quot;main&quot; as extension name.
        </p>
        <p class="para">
         <div class="example" id="example-374">
          <p><strong>Example #10 <em>--ri</em> 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">Note</strong>: 
   <p class="para">
    Options <em>-rBRFEH</em>, <em>--ini</em> and
    <em>--r[fcezi]</em> are available only in <acronym title="Command Line Interpreter/Interface">CLI</acronym>.
   </p>
  </p></blockquote>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="features.commandline.differences.html">Differences to other SAPIs</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="features.commandline.usage.html">Usage</a></div>
 <div class="up"><a href="features.commandline.html">Command line usage</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>