PHP from the command line

These are examples that work from the command line in a shell prompt. This way, PHP can be used as simple scripting language, e.g. to massage files or maintain databases.

Clicking on *.php files above will lead to uninteresting results. You have to copy them locally and have php yourself.

(Note that you need to have installed a non-apache/simple cgi-version of PHP.)

Command line flags for the php executable

Type 'php -h' to see the command-line flags:
Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>] | {<file> [args...]}
  -q       Quiet-mode.  Suppress HTTP Header output.
  -s       Display colour syntax highlighted source.
  -f<file> Parse <file>.  Implies `-q'
  -v       Version number
  -p       Pretokenize a script (creates a .php3p file)
  -e       Execute a pretokenized (.php3p) script
  -c<path> Look for php3.ini file in this directory
  -i       PHP information
  -h       This help

Process arguments

See arguments.text

Basically you have to look into the $argv array.

PHP as preprocessor for static HTML files

 php -q filename.php > filename.html
... and upload filename.html

Note to MS-DOS / Winxx) Users

If you want to play with PHP as a programming language:


D.K.S.