~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to sapi/cli/php.1.in

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
./"    +----------------------------------------------------------------------+
 
2
./"    | PHP Version 5                                                        |
 
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
./"    +----------------------------------------------------------------------+
 
16
./" 
 
17
./" $Id: php.1.in,v 1.7.2.1 2005/04/30 04:12:43 sniper Exp $
 
18
./" 
 
19
.TH PHP 1 "Feb 2003" "The PHP Group" "Scripting Language"
 
20
.SH NAME
 
21
.TP 15
 
22
.B php
 
23
PHP Command Line Interface 'CLI'
 
24
.SH SYNOPSIS
 
25
.B php
 
26
[options] [
 
27
.B \-f ]
 
28
.IR file
 
29
[[\-\-] 
 
30
.IR args.\|.\|. ]
 
31
.LP
 
32
.B php
 
33
[options] 
 
34
.B \-r 
 
35
.IR code
 
36
[[\-\-]
 
37
.IR args.\|.\|. ]
 
38
.LP
 
39
.B php
 
40
[options] [\-B 
 
41
.IR code ] 
 
42
.B \-R 
 
43
.IR code
 
44
[\-E 
 
45
.IR code ]
 
46
[[\-\-]
 
47
.IR args.\|.\|. ]
 
48
.LP
 
49
.B php
 
50
[options] [\-B 
 
51
.IR code ]
 
52
.B \-F 
 
53
.IR file
 
54
[\-E 
 
55
.IR code ] 
 
56
[[\-\-]
 
57
.IR args.\|.\|. ]
 
58
.LP
 
59
.B php
 
60
[options] \-\- [
 
61
.IR args.\|.\|. ]
 
62
.LP
 
63
.SH DESCRIPTION
 
64
.B PHP
 
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:
 
68
.P
 
69
You can parse and execute files by using parameter \-f followed by the name of the 
 
70
.IR file 
 
71
to be executed.
 
72
.LP
 
73
Using parameter \-r you can directly execute PHP 
 
74
.IR code 
 
75
simply as you would do inside a
 
76
.B \.php
 
77
file when using the 
 
78
.B eval() 
 
79
function.
 
80
.LP
 
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
 
83
.IR code 
 
84
specified by \-R or the 
 
85
.IR file
 
86
specified by \-F to be executed.
 
87
You can access the input line by \fB$argn\fP. While processing the input lines
 
88
.B $argi 
 
89
contains the number of the actual line being processed. Further more
 
90
the paramters \-B and \-E can be used to execute 
 
91
.IR code
 
92
(see \-r) before and
 
93
after all input lines have been processed respectively. Notice that the
 
94
input is read from
 
95
.B STDIN
 
96
and therefore reading from 
 
97
.B STDIN 
 
98
explicitly changes the next input line or skips input lines.
 
99
.LP
 
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 
 
103
executed.
 
104
.SH OPTIONS
 
105
.TP 15
 
106
.PD 0
 
107
.B \-\-interactive
 
108
.TP
 
109
.PD 1
 
110
.B \-a
 
111
Run interactively
 
112
.TP
 
113
.PD 0
 
114
.B \-\-php\-ini \fIpath\fP|\fIfile\fP
 
115
.TP
 
116
.PD 1
 
117
.B \-c \fIpath\fP|\fIfile\fP
 
118
Look for 
 
119
.B php.ini 
 
120
file in the directory
 
121
.IR path
 
122
or use the specified
 
123
.IR file
 
124
.TP
 
125
.PD 0
 
126
.B \-\-no\-php\-ini
 
127
.TP
 
128
.PD 1
 
129
.B \-n
 
130
No 
 
131
.B php.ini 
 
132
file will be used
 
133
.TP
 
134
.PD 0
 
135
.B \-\-define \fIfoo\fP[=\fIbar\fP]
 
136
.TP
 
137
.PD 1
 
138
.B \-d \fIfoo\fP[=\fIbar\fP]
 
139
Define INI entry 
 
140
.IR foo 
 
141
with value
 
142
.IR bar
 
143
.TP
 
144
.B \-e
 
145
Generate extended information for debugger/profiler
 
146
.TP
 
147
.PD 0
 
148
.B \-\-file \fIfile\fP
 
149
.TP
 
150
.PD 1
 
151
.B \-f \fIfile\fP
 
152
Parse and execute 
 
153
.IR file
 
154
.TP
 
155
.PD 0
 
156
.B \-\-global \fIname\fP
 
157
.TP
 
158
.PD 1
 
159
.B \-g \fIname\fP
 
160
Make variable
 
161
.IR name
 
162
global in script.
 
163
.TP
 
164
.PD 0
 
165
.B \-\-help
 
166
.TP
 
167
.PD 1
 
168
.B \-h
 
169
This help
 
170
.TP
 
171
.PD 0
 
172
.B \-\-hide\-args
 
173
.TP
 
174
.PD 1
 
175
.B \-H
 
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.
 
179
.TP
 
180
.PD 0
 
181
.B \-\-info
 
182
.TP
 
183
.PD 1
 
184
.B \-i
 
185
PHP information and configuration
 
186
.TP
 
187
.PD 0
 
188
.B \-\-syntax\-check
 
189
.TP
 
190
.PD 1
 
191
.B \-l
 
192
Syntax check only (lint)
 
193
.TP
 
194
.PD 0
 
195
.B \-\-modules
 
196
.TP
 
197
.PD 1
 
198
.B \-m
 
199
Show compiled in modules
 
200
.TP
 
201
.PD 0
 
202
.B \-\-run \fIcode\fP
 
203
.TP
 
204
.PD 1
 
205
.B \-r \fIcode\fP
 
206
Run PHP 
 
207
.IR code
 
208
without using script tags
 
209
.B '<?..?>'
 
210
.TP
 
211
.PD 0
 
212
.B \-\-process\-begin \fIcode\fP
 
213
.TP
 
214
.PD 1
 
215
.B \-B \fIcode\fP
 
216
Run PHP 
 
217
.IR code
 
218
before processing input lines
 
219
.TP
 
220
.PD 0
 
221
.B \-\-process\-code \fIcode\fP
 
222
.TP
 
223
.PD 1
 
224
.B \-R \fIcode\fP
 
225
Run PHP 
 
226
.IR code
 
227
for every input line
 
228
.TP
 
229
.PD 0
 
230
.B \-\-process\-file \fIfile\fP
 
231
.TP
 
232
.PD 1
 
233
.B \-F \fIfile\fP
 
234
Parse and execute 
 
235
.IR file
 
236
for every input line
 
237
.TP
 
238
.PD 0
 
239
.B \-\-process\-end \fIcode\fP
 
240
.TP
 
241
.PD 1
 
242
.B \-E \fIcode\fP
 
243
Run PHP 
 
244
.IR code
 
245
after processing all input lines
 
246
.TP
 
247
.PD 0
 
248
.B \-\-syntax\-highlight
 
249
.TP
 
250
.PD 1
 
251
.B \-s
 
252
Display colour syntax highlighted source
 
253
.TP
 
254
.PD 0
 
255
.B \-\-version
 
256
.TP
 
257
.PD 1
 
258
.B \-v
 
259
Version number
 
260
.TP
 
261
.PD 0
 
262
.B \-\-stripped
 
263
.TP
 
264
.PD 1
 
265
.B \-w
 
266
Display source with stripped comments and whitespace
 
267
.TP
 
268
.PD 0
 
269
.B \-\-zend\-extension \fIfile\fP
 
270
.TP
 
271
.PD 1
 
272
.B \-z \fIfile\fP
 
273
Load Zend extension 
 
274
.IR file
 
275
.TP
 
276
.IR args.\|.\|.
 
277
Arguments passed to script. Use 
 
278
.B '\-\-'
 
279
.IR args
 
280
when first argument starts with 
 
281
.B '\-'
 
282
or script is read from stdin
 
283
.SH FILES
 
284
.TP 15
 
285
.B php\-cli.ini
 
286
The configuration file for the CLI version of PHP.
 
287
.TP
 
288
.B php.ini
 
289
The standard configuration file will only be used when 
 
290
.B php\-cli.ini
 
291
cannot be found.
 
292
.SH EXAMPLES
 
293
.TP 5
 
294
\fIphp -r 'echo "Hello World\\n";'\fP
 
295
This command simply writes the text "Hello World" to standard out.
 
296
.TP
 
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:
 
303
.RS
 
304
\fIphp \-r 'print_r(dba_handlers(1));'\fP
 
305
.RE
 
306
.TP
 
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.
 
313
.TP
 
314
\fIphp \-E 'echo "Lines: $argi\\n";'\fP
 
315
Using this PHP command you can count the lines being input.
 
316
.TP
 
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.
 
321
.TP
 
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.
 
327
.SH TIPS
 
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:
 
331
.P
 
332
.PD 0
 
333
.RS
 
334
#!/bin/php
 
335
.P
 
336
<?php
 
337
.P
 
338
 // your script
 
339
.P
 
340
?>
 
341
.RE
 
342
.PD 1
 
343
.P
 
344
.SH SEE ALSO
 
345
For a more or less complete description of PHP look here:
 
346
.PD 0
 
347
.P
 
348
.B http://www.php.net/manual/
 
349
.PD 1
 
350
.P
 
351
A nice introduction to PHP by Stig Bakken can be found here:
 
352
.PD 0
 
353
.P
 
354
.B http://www.zend.com/zend/art/intro.php
 
355
.PD 1
 
356
.SH BUGS
 
357
You can view the list of known bugs or add any new bug you
 
358
found here:
 
359
.PD 0
 
360
.P
 
361
.B http://bugs.php.net
 
362
.PD 1
 
363
.SH AUTHORS
 
364
The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski.
 
365
.P
 
366
Additional work for the CLI sapi was done by Edin Kadribasic and Marcus Boerger.
 
367
.P
 
368
A List of active developers can be found here:
 
369
.PD 0
 
370
.P
 
371
.B http://www.php.net/credits.php
 
372
.PD 1
 
373
.P
 
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@.
 
378
.SH COPYRIGHT
 
379
Copyright \(co 1997\-2004 The PHP Group
 
380
.LP
 
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
 
384
.PD 0
 
385
.P
 
386
.B http://www.php.net/license/3_0.txt
 
387
.PD 1
 
388
.P
 
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
 
391
.B license@php.net 
 
392
so we can mail you a copy immediately.