1: .TH PHP 1 "2010" "The PHP Group" "Scripting Language"
2: .SH NAME
3: php \- PHP Command Line Interface 'CLI'
4: .SH SYNOPSIS
5: .B php
6: [options] [
7: .B \-f\fP ]
8: .IR file
9: [[\-\-]
10: .IR args.\|.\|. ]
11: .LP
12: .B php
13: [options]
14: .B \-r
15: .IR code
16: [[\-\-]
17: .IR args.\|.\|. ]
18: .LP
19: .B php
20: [options] [\-B
21: .IR code ]
22: .B \-R
23: .IR code
24: [\-E
25: .IR code ]
26: [[\-\-]
27: .IR args.\|.\|. ]
28: .LP
29: .B php
30: [options] [\-B
31: .IR code ]
32: .B \-F
33: .IR file
34: [\-E
35: .IR code ]
36: [[\-\-]
37: .IR args.\|.\|. ]
38: .LP
39: .B php
40: [options] \-\- [
41: .IR args.\|.\|. ]
42: .LP
43: \fBphp \fP[options] \fB\-a\fP
44: .LP
45: .SH DESCRIPTION
46: \fBPHP\fP is a widely\-used general\-purpose scripting language that is especially suited for
47: Web development and can be embedded into HTML. This is the command line interface
48: that enables you to do the following:
49: .P
50: You can parse and execute files by using parameter \-f followed by the name of the
51: .IR file
52: to be executed.
53: .LP
54: Using parameter \-r you can directly execute PHP
55: .IR code
56: simply as you would do inside a
57: .B \.php
58: file when using the
59: .B eval()
60: function.
61: .LP
62: It is also possible to process the standard input line by line using either
63: the parameter \-R or \-F. In this mode each separate input line causes the
64: .IR code
65: specified by \-R or the
66: .IR file
67: specified by \-F to be executed.
68: You can access the input line by \fB$argn\fP. While processing the input lines
69: .B $argi
70: contains the number of the actual line being processed. Further more
71: the parameters \-B and \-E can be used to execute
72: .IR code
73: (see \-r) before and
74: after all input lines have been processed respectively. Notice that the
75: input is read from
76: .B STDIN
77: and therefore reading from
78: .B STDIN
79: explicitly changes the next input line or skips input lines.
80: .LP
81: If none of \-r \-f \-B \-R \-F or \-E is present but a single parameter is given
82: then this parameter is taken as the filename to parse and execute (same as
83: with \-f). If no parameter is present then the standard input is read and
84: executed.
85: .SH OPTIONS
86: .TP 15
87: .PD 0
88: .B \-\-interactive
89: .TP
90: .PD 1
91: .B \-a
92: Run PHP interactively. This lets you enter snippets of PHP code that directly
93: get executed. When readline support is enabled you can edit the lines and also
94: have history support.
95: .TP
96: .PD 0
97: .B \-\-bindpath \fIaddress:port\fP|\fIport\fP
98: .TP
99: .PD 1
100: .B \-b \fIaddress:port\fP|\fIport\fP
101: Bind Path for external FASTCGI Server mode (CGI only).
102: .TP
103: .PD 0
104: .B \-\-no\-chdir
105: .TP
106: .PD 1
107: .B \-C
108: Do not chdir to the script's directory (CGI only).
109: .TP
110: .PD 0
111: .B \-\-no\-header
112: .TP
113: .PD 1
114: .B \-q
115: Quiet-mode. Suppress HTTP header output (CGI only).
116: .TP
117: .PD 0
118: .B \-\-timing \fIcount\fP
119: .TP
120: .PD 1
121: .B \-T \fIcount\fP
122: Measure execution time of script repeated count times (CGI only).
123: .TP
124: .PD 0
125: .B \-\-php\-ini \fIpath\fP|\fIfile\fP
126: .TP
127: .PD 1
128: .B \-c \fIpath\fP|\fIfile\fP
129: Look for
130: .B php.ini
131: file in the directory
132: .IR path
133: or use the specified
134: .IR file
135: .TP
136: .PD 0
137: .B \-\-no\-php\-ini
138: .TP
139: .PD 1
140: .B \-n
141: No
142: .B php.ini
143: file will be used
144: .TP
145: .PD 0
146: .B \-\-define \fIfoo\fP[=\fIbar\fP]
147: .TP
148: .PD 1
149: .B \-d \fIfoo\fP[=\fIbar\fP]
150: Define INI entry
151: .IR foo
152: with value
153: .IR bar
154: .TP
155: .B \-e
156: Generate extended information for debugger/profiler
157: .TP
158: .PD 0
159: .B \-\-file \fIfile\fP
160: .TP
161: .PD 1
162: .B \-f \fIfile\fP
163: Parse and execute
164: .IR file
165: .TP
166: .PD 0
167: .B \-\-global \fIname\fP
168: .TP
169: .PD 1
170: .B \-g \fIname\fP
171: Make variable
172: .IR name
173: global in script.
174: .TP
175: .PD 0
176: .B \-\-help
177: .TP
178: .PD 1
179: .B \-h
180: This help
181: .TP
182: .PD 0
183: .B \-\-hide\-args
184: .TP
185: .PD 1
186: .B \-H
187: Hide script name (\fIfile\fP) and parameters (\fIargs\.\.\.\fP) from external
188: tools. For example you may want to use this when a php script is started as
189: a daemon and the command line contains sensitive data such as passwords.
190: .TP
191: .PD 0
192: .B \-\-info
193: .TP
194: .PD 1
195: .B \-i
196: PHP information and configuration
197: .TP
198: .PD 0
199: .B \-\-syntax\-check
200: .TP
201: .PD 1
202: .B \-l
203: Syntax check only (lint)
204: .TP
205: .PD 0
206: .B \-\-modules
207: .TP
208: .PD 1
209: .B \-m
210: Show compiled in modules
211: .TP
212: .PD 0
213: .B \-\-run \fIcode\fP
214: .TP
215: .PD 1
216: .B \-r \fIcode\fP
217: Run PHP
218: .IR code
219: without using script tags
220: .B '<?..?>'
221: .TP
222: .PD 0
223: .B \-\-process\-begin \fIcode\fP
224: .TP
225: .PD 1
226: .B \-B \fIcode\fP
227: Run PHP
228: .IR code
229: before processing input lines
230: .TP
231: .PD 0
232: .B \-\-process\-code \fIcode\fP
233: .TP
234: .PD 1
235: .B \-R \fIcode\fP
236: Run PHP
237: .IR code
238: for every input line
239: .TP
240: .PD 0
241: .B \-\-process\-file \fIfile\fP
242: .TP
243: .PD 1
244: .B \-F \fIfile\fP
245: Parse and execute
246: .IR file
247: for every input line
248: .TP
249: .PD 0
250: .B \-\-process\-end \fIcode\fP
251: .TP
252: .PD 1
253: .B \-E \fIcode\fP
254: Run PHP
255: .IR code
256: after processing all input lines
257: .TP
258: .PD 0
259: .B \-\-syntax\-highlight
260: .TP
261: .PD 1
262: .B \-s
263: Output HTML syntax highlighted source
264: .TP
265: .PD 0
266: .B \-\-version
267: .TP
268: .PD 1
269: .B \-v
270: Version number
271: .TP
272: .PD 0
273: .B \-\-stripped
274: .TP
275: .PD 1
276: .B \-w
277: Output source with stripped comments and whitespace
278: .TP
279: .PD 0
280: .B \-\-zend\-extension \fIfile\fP
281: .TP
282: .PD 1
283: .B \-z \fIfile\fP
284: Load Zend extension
285: .IR file
286: .TP
287: .IR args.\|.\|.
288: Arguments passed to script. Use
289: .B '\-\-'
290: .IR args
291: when first argument starts with
292: .B '\-'
293: or script is read from stdin
294: .TP
295: .PD 0
296: .B \-\-rfunction
297: .IR name
298: .TP
299: .PD 1
300: .B \-\-rf
301: .IR name
302: Shows information about function
303: .B name
304: .TP
305: .PD 0
306: .B \-\-rclass
307: .IR name
308: .TP
309: .PD 1
310: .B \-\-rc
311: .IR name
312: Shows information about class
313: .B name
314: .TP
315: .PD 0
316: .B \-\-rextension
317: .IR name
318: .TP
319: .PD 1
320: .B \-\-re
321: .IR name
322: Shows information about extension
323: .B name
324: .TP
325: .PD 0
326: .B \-\-rextinfo
327: .IR name
328: .TP
329: .PD 1
330: .B \-\-ri
331: .IR name
332: Shows configuration for extension
333: .B name
334: .TP
335: .B \-\-ini
336: Show configuration file names
337: .SH FILES
338: .TP 15
339: .B php\-cli.ini
340: The configuration file for the CLI version of PHP.
341: .TP
342: .B php.ini
343: The standard configuration file will only be used when
344: .B php\-cli.ini
345: cannot be found.
346: .SH EXAMPLES
347: .TP 5
348: \fIphp \-r 'echo "Hello World\\n";'\fP
349: This command simply writes the text "Hello World" to standard out.
350: .TP
351: \fIphp \-r 'print_r(gd_info());'\fP
352: This shows the configuration of your gd extension. You can use this
353: to easily check which image formats you can use. If you have any
354: dynamic modules you may want to use the same ini file that php uses
355: when executed from your webserver. There are more extensions which
356: have such a function. For dba use:
357: .RS
358: \fIphp \-r 'print_r(dba_handlers(1));'\fP
359: .RE
360: .TP
361: \fIphp \-R 'echo strip_tags($argn)."\\n";'\fP
362: This PHP command strips off the HTML tags line by line and outputs the
363: result. To see how it works you can first look at the following PHP command
364: \'\fIphp \-d html_errors=1 \-i\fP\' which uses PHP to output HTML formatted
365: configuration information. If you then combine those two
366: \'\fIphp \.\.\.|php \.\.\.\fP\' you'll see what happens.
367: .TP
368: \fIphp \-E 'echo "Lines: $argi\\n";'\fP
369: Using this PHP command you can count the lines being input.
370: .TP
371: \fIphp \-R '@$l+=count(file($argn));' \-E 'echo "Lines:$l\\n";'\fP
372: In this example PHP expects each input line being a file. It counts all lines
373: of the files specified by each input line and shows the summarized result.
374: You may combine this with tools like find and change the php scriptlet.
375: .TP
376: \fIphp \-R 'echo "$argn\\n"; fgets(STDIN);'\fP
377: Since you have access to STDIN from within \-B \-R \-F and \-E you can skip
378: certain input lines with your code. But note that in such cases $argi only
379: counts the lines being processed by php itself. Having read this you will
380: guess what the above program does: skipping every second input line.
381: .SH TIPS
382: You can use a shebang line to automatically invoke php
383: from scripts. Only the CLI version of PHP will ignore
384: such a first line as shown below:
385: .P
386: .PD 0
387: .RS
388: #!/bin/php
389: .P
390: <?php
391: .P
392: // your script
393: .P
394: ?>
395: .RE
396: .PD 1
397: .P
398: .SH SEE ALSO
399: For a more or less complete description of PHP look here:
400: .PD 0
401: .P
402: .B http://www.php.net/manual/
403: .PD 1
404: .P
405: .SH BUGS
406: You can view the list of known bugs or report any new bug you
407: found at:
408: .PD 0
409: .P
410: .B http://bugs.php.net
411: .PD 1
412: .SH AUTHORS
413: The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski.
414: .P
415: Additional work for the CLI sapi was done by Edin Kadribasic, Marcus Boerger and Johannes Schlueter.
416: .P
417: A List of active developers can be found here:
418: .PD 0
419: .P
420: .B http://www.php.net/credits.php
421: .PD 1
422: .P
423: And last but not least PHP was developed with the help of a huge amount of
424: contributors all around the world.
425: .SH VERSION INFORMATION
426: This manpage describes \fBphp\fP, version @PHP_VERSION@.
427: .SH COPYRIGHT
428: Copyright \(co 1997\-2010 The PHP Group
429: .LP
430: This source file is subject to version 3.01 of the PHP license,
431: that is bundled with this package in the file LICENSE, and is
432: available through the world-wide-web at the following url:
433: .PD 0
434: .P
435: .B http://www.php.net/license/3_01.txt
436: .PD 1
437: .P
438: If you did not receive a copy of the PHP license and are unable to
439: obtain it through the world-wide-web, please send a note to
440: .B license@php.net
441: so we can mail you a copy immediately.
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>