1PHP(1) Scripting Language PHP(1)
2
3
4
6 php - PHP Command Line Interface 'CLI'
7
9 php [options] [ -f ] file [[--] args...]
10
11 php [options] -r code [[--] args...]
12
13 php [options] [-B code] -R code [-E code] [[--] args...]
14
15 php [options] [-B code] -F file [-E code] [[--] args...]
16
17 php [options] -- [ args...]
18
19 php [options] -a
20
22 PHP is a widely-used general-purpose scripting language that is espe‐
23 cially suited for Web development and can be embedded into HTML. This
24 is the command line interface that enables you to do the following:
25
26 You can parse and execute files by using parameter -f followed by the
27 name of the file to be executed.
28
29 Using parameter -r you can directly execute PHP code simply as you
30 would do inside a .php file when using the eval() function.
31
32 It is also possible to process the standard input line by line using
33 either the parameter -R or -F. In this mode each separate input line
34 causes the code specified by -R or the file specified by -F to be exe‐
35 cuted. You can access the input line by $argn. While processing the
36 input lines $argi contains the number of the actual line being pro‐
37 cessed. Further more the parameters -B and -E can be used to execute
38 code (see -r) before and after all input lines have been processed
39 respectively. Notice that the input is read from STDIN and therefore
40 reading from STDIN explicitly changes the next input line or skips
41 input lines.
42
43 If none of -r -f -B -R -F or -E is present but a single parameter is
44 given then this parameter is taken as the filename to parse and execute
45 (same as with -f). If no parameter is present then the standard input
46 is read and executed.
47
49 --interactive
50 -a Run PHP interactively. This lets you enter snippets of
51 PHP code that directly get executed. When readline sup‐
52 port is enabled you can edit the lines and also have
53 history support.
54
55 --bindpath address:port|port
56 -b address:port|port
57 Bind Path for external FASTCGI Server mode (CGI only).
58
59 --no-chdir
60 -C Do not chdir to the script's directory (CGI only).
61
62 --no-header
63 -q Quiet-mode. Suppress HTTP header output (CGI only).
64
65 --timing count
66 -T count Measure execution time of script repeated count times
67 (CGI only).
68
69 --php-ini path|file
70 -c path|file Look for php.ini file in the directory path or use the
71 specified file
72
73 --no-php-ini
74 -n No php.ini file will be used
75
76 --define foo[=bar]
77 -d foo[=bar] Define INI entry foo with value bar
78
79 -e Generate extended information for debugger/profiler
80
81 --file file
82 -f file Parse and execute file
83
84 --global name
85 -g name Make variable name global in script.
86
87 --help
88 -h This help
89
90 --hide-args
91 -H Hide script name (file) and parameters (args...) from
92 external tools. For example you may want to use this
93 when a php script is started as a daemon and the command
94 line contains sensitive data such as passwords.
95
96 --info
97 -i PHP information and configuration
98
99 --syntax-check
100 -l Syntax check only (lint)
101
102 --modules
103 -m Show compiled in modules
104
105 --run code
106 -r code Run PHP code without using script tags '<?..?>'
107
108 --process-begin code
109 -B code Run PHP code before processing input lines
110
111 --process-code code
112 -R code Run PHP code for every input line
113
114 --process-file file
115 -F file Parse and execute file for every input line
116
117 --process-end code
118 -E code Run PHP code after processing all input lines
119
120 --syntax-highlight
121 -s Output HTML syntax highlighted source
122
123 --version
124 -v Version number
125
126 --stripped
127 -w Output source with stripped comments and whitespace
128
129 --zend-extension file
130 -z file Load Zend extension file
131
132 args... Arguments passed to script. Use '--' args when first
133 argument starts with '-' or script is read from stdin
134
135 --rfunction name
136 --rf name Shows information about function name
137
138 --rclass name
139 --rc name Shows information about class name
140
141 --rextension name
142 --re name Shows information about extension name
143
144 --rextinfo name
145 --ri name Shows configuration for extension name
146
147 --ini Show configuration file names
148
150 php-cli.ini The configuration file for the CLI version of PHP.
151
152 php.ini The standard configuration file will only be used when
153 php-cli.ini cannot be found.
154
156 php -r 'echo "Hello World\n";'
157 This command simply writes the text "Hello World" to standard out.
158
159 php -r 'print_r(gd_info());'
160 This shows the configuration of your gd extension. You can use
161 this to easily check which image formats you can use. If you have
162 any dynamic modules you may want to use the same ini file that php
163 uses when executed from your webserver. There are more extensions
164 which have such a function. For dba use:
165 php -r 'print_r(dba_handlers(1));'
166
167 php -R 'echo strip_tags($argn)."\n";'
168 This PHP command strips off the HTML tags line by line and outputs
169 the result. To see how it works you can first look at the follow‐
170 ing PHP command ´php -d html_errors=1 -i´ which uses PHP to output
171 HTML formatted configuration information. If you then combine
172 those two ´php ...|php ...´ you'll see what happens.
173
174 php -E 'echo "Lines: $argi\n";'
175 Using this PHP command you can count the lines being input.
176
177 php -R '@$l+=count(file($argn));' -E 'echo "Lines:$l\n";'
178 In this example PHP expects each input line being a file. It
179 counts all lines of the files specified by each input line and
180 shows the summarized result. You may combine this with tools like
181 find and change the php scriptlet.
182
183 php -R 'echo "$argn\n"; fgets(STDIN);'
184 Since you have access to STDIN from within -B -R -F and -E you can
185 skip certain input lines with your code. But note that in such
186 cases $argi only counts the lines being processed by php itself.
187 Having read this you will guess what the above program does: skip‐
188 ping every second input line.
189
191 You can use a shebang line to automatically invoke php from scripts.
192 Only the CLI version of PHP will ignore such a first line as shown
193 below:
194
195 #!/bin/php
196 <?php
197 // your script
198 ?>
199
201 For a more or less complete description of PHP look here:
202 http://www.php.net/manual/
203
205 You can view the list of known bugs or report any new bug you found at:
206 http://bugs.php.net
207
209 The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Ler‐
210 dorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei
211 Zmievski.
212
213 Additional work for the CLI sapi was done by Edin Kadribasic, Marcus
214 Boerger and Johannes Schlueter.
215
216 A List of active developers can be found here:
217 http://www.php.net/credits.php
218
219 And last but not least PHP was developed with the help of a huge amount
220 of contributors all around the world.
221
223 This manpage describes php, version 5.3.8.
224
226 Copyright © 1997-2010 The PHP Group
227
228 This source file is subject to version 3.01 of the PHP license, that is
229 bundled with this package in the file LICENSE, and is available through
230 the world-wide-web at the following url:
231 http://www.php.net/license/3_01.txt
232
233 If you did not receive a copy of the PHP license and are unable to
234 obtain it through the world-wide-web, please send a note to
235 license@php.net so we can mail you a copy immediately.
236
237
238
239The PHP Group 2010 PHP(1)