Activate the extended information mode, to be used by a
debugger/profiler.

-f

--file

Parse and execute the specified file. The
-f
is optional and may be omitted - providing just
the filename to execute is sufficient.

Note:

To pass arguments to a script, the first argument must be
--, otherwise PHP will interpret them as PHP
options.

-h and -?

--help and --usage

Output a list of
command line options with one line descriptions of what they do.

-i

--info

Calls phpinfo(), and prints out the results.
If PHP is not working correctly, it is advisable to use the command
php -i and see whether any error
messages are printed out before or in place of the information tables.
Beware that when using the CGI mode the output is in
HTML and therefore very large.

-l

--syntax-check

Provides a convenient way to perform only a syntax check
on the given PHP code. On success, the text
No syntax errors detected in <filename> is
written to standard output and the shell return code is
0. On failure, the text Errors parsing
<filename> in addition to the internal parser error
message is written to standard output and the shell return code is set
to -1.

The problem here is that sh/bash performs variable substitution
even when using double quotes ". Since the
variable $foo is unlikely to be defined, it
expands to nothing which results in the code passed to
PHP for execution actually reading:

$ php -r " = get_defined_constants();"

The correct way would be to use single quotes '.
Variables in single-quoted strings are not expanded
by sh/bash.

Example #3 Using single quotes to prevent the shell's variable
substitution

If using a shell other than sh/bash, further issues might be
experienced - if appropriate, a bug report should be opened at
» http://bugs.php.net/.
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!

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> [...] </code>
HTML tags, no HTML headers.

Note:

This option does not work together with the -r
option.

-v

--version

Example #5 Using -v
to get the SAPI
name and the version of PHP and Zend

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 /etc/ld.so.conf on Linux systems, for
example). Passing a filename with an absolute path will
not use the system's library search path. A relative filename including
directory information will tell PHP to try
loading the extension relative to the current directory.

--ini

Show configuration file names and scanned directories. Available as
of PHP 5.2.3.

Show the configuration information for the given Zend extension (the
same information that is returned by phpinfo()).
Available as of PHP 5.4.0.

--ri

--rextinfo

Show the configuration information for the given extension (the same
information that is returned by phpinfo()).
Available as of PHP 5.2.2. The core configuration information
is available using "main" as extension name.

User Contributed Notes 1 note

If we start the php's built in webserver (PHP v5.4 onwards) with: php -S localhost:8000 -t htdocsand have an image file picture.jpg in itand reference it in a html page with: <img src="picture.jpg">the rendered page will not show the image and the html code behind the image is:http://localhost:8000/index.php/picture.jpg

If however, the html code in the page is: <img src="/picture.jpg">the picture displays correctly.