1
./" +----------------------------------------------------------------------+
3
./" +----------------------------------------------------------------------+
4
./" | Copyright (c) 1997-2004 The PHP Group |
5
./" +----------------------------------------------------------------------+
6
./" | This source file is subject to version 3.0 of the PHP license, |
7
./" | that is bundled with this package in the file LICENSE, and is |
8
./" | available through the world-wide-web at the following url: |
9
./" | http://www.php.net/license/3_0.txt. |
10
./" | If you did not receive a copy of the PHP license and are unable to |
11
./" | obtain it through the world-wide-web, please send a note to |
12
./" | license@php.net so we can mail you a copy immediately. |
13
./" +----------------------------------------------------------------------+
14
./" | Author: Marcus Boerger <helly@php.net> |
15
./" +----------------------------------------------------------------------+
17
./" $Id: php.1.in,v 1.7.2.1 2005/04/30 04:12:43 sniper Exp $
19
.TH PHP 1 "Feb 2003" "The PHP Group" "Scripting Language"
23
PHP Command Line Interface 'CLI'
65
is a widely\-used general\-purpose scripting language that is especially suited for
66
Web development and can be embedded into HTML. This is the command line interface
67
that enables you to the following:
69
You can parse and execute files by using parameter \-f followed by the name of the
73
Using parameter \-r you can directly execute PHP
75
simply as you would do inside a
81
It is also possible to process the standard input line by line using either
82
the parameter \-R or \-F. In this mode each separate input line causes the
84
specified by \-R or the
86
specified by \-F to be executed.
87
You can access the input line by \fB$argn\fP. While processing the input lines
89
contains the number of the actual line being processed. Further more
90
the paramters \-B and \-E can be used to execute
93
after all input lines have been processed respectively. Notice that the
96
and therefore reading from
98
explicitly changes the next input line or skips input lines.
100
If none of \-r \-f \-B \-R \-F or \-E is present but a single parameter is given
101
then this parameter is taken as the filename to parse and execute (same as
102
with \-f). If no parameter is present then the standard input is read and
114
.B \-\-php\-ini \fIpath\fP|\fIfile\fP
117
.B \-c \fIpath\fP|\fIfile\fP
120
file in the directory
135
.B \-\-define \fIfoo\fP[=\fIbar\fP]
138
.B \-d \fIfoo\fP[=\fIbar\fP]
145
Generate extended information for debugger/profiler
148
.B \-\-file \fIfile\fP
156
.B \-\-global \fIname\fP
176
Hide script name (\fIfile\fP) and parameters (\fIargs\.\.\.\fP) from external
177
tools. For example you may want to use this when a php script is started as
178
a daemon and the command line contains sensitive data such as passwords.
185
PHP information and configuration
192
Syntax check only (lint)
199
Show compiled in modules
202
.B \-\-run \fIcode\fP
208
without using script tags
212
.B \-\-process\-begin \fIcode\fP
218
before processing input lines
221
.B \-\-process\-code \fIcode\fP
230
.B \-\-process\-file \fIfile\fP
239
.B \-\-process\-end \fIcode\fP
245
after processing all input lines
248
.B \-\-syntax\-highlight
252
Display colour syntax highlighted source
266
Display source with stripped comments and whitespace
269
.B \-\-zend\-extension \fIfile\fP
277
Arguments passed to script. Use
280
when first argument starts with
282
or script is read from stdin
286
The configuration file for the CLI version of PHP.
289
The standard configuration file will only be used when
294
\fIphp -r 'echo "Hello World\\n";'\fP
295
This command simply writes the text "Hello World" to standard out.
297
\fIphp \-r 'print_r(gd_info());'\fP
298
This shows the configuration of your gd extension. You can use this
299
to easily check which image formats you can use. If you have any
300
dynamic modules you may want to use the same ini file that php uses
301
when executed from your webserver. There are more extensions which
302
have such a function. For dba use:
304
\fIphp \-r 'print_r(dba_handlers(1));'\fP
307
\fIphp \-R 'echo strip_tags($argn)."\\n";'\fP
308
This PHP command strips off the HTML tags line by line and outputs the
309
result. To see how it works you can first look at the following PHP command
310
\'\fIphp \-d html_errors=1 \-i\fP\' which uses PHP to output HTML formatted
311
configuration information. If you then combine those two
312
\'\fIphp \.\.\.|php \.\.\.\fP\' you'll see what happens.
314
\fIphp \-E 'echo "Lines: $argi\\n";'\fP
315
Using this PHP command you can count the lines being input.
317
\fIphp \-R '@$l+=count(file($argn));' \-E 'echo "Lines:$l\\n";'\fP
318
In this example PHP expects each input line beeing a file. It counts all lines
319
of the files specified by each input line and shows the summarized result.
320
You may combine this with tools like find and change the php scriptlet.
322
\fIphp \-R 'echo "$argn\\n"; fgets(STDIN);'\fP
323
Since you have access to STDIN from within \-B \-R \-F and \-E you can skip
324
certain input lines with your code. But note that in such cases $argi only
325
counts the lines being processed by php itself. Having read this you will
326
guess what the above program does: skipping every second input line.
328
You can use a shebang line to automatically invoke php
329
from scripts. Only the CLI version of PHP will ignore
330
such a first line as shown below:
345
For a more or less complete description of PHP look here:
348
.B http://www.php.net/manual/
351
A nice introduction to PHP by Stig Bakken can be found here:
354
.B http://www.zend.com/zend/art/intro.php
357
You can view the list of known bugs or add any new bug you
361
.B http://bugs.php.net
364
The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski.
366
Additional work for the CLI sapi was done by Edin Kadribasic and Marcus Boerger.
368
A List of active developers can be found here:
371
.B http://www.php.net/credits.php
374
And last but not least PHP was developed with the help of a huge amount of
375
contributors all around the world.
376
.SH VERSION INFORMATION
377
This manpage describes \fBphp\fP, version @PHP_VERSION@.
379
Copyright \(co 1997\-2004 The PHP Group
381
This source file is subject to version 3.0 of the PHP license,
382
that is bundled with this package in the file LICENSE, and is
383
available at through the world-wide-web at
386
.B http://www.php.net/license/3_0.txt
389
If you did not receive a copy of the PHP license and are unable to
390
obtain it through the world-wide-web, please send a note to
392
so we can mail you a copy immediately.