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