1PHP(1)                        Scripting Language                        PHP(1)
2
3
4

NAME

6       php - PHP Command Line Interface 'CLI'
7
8       php-cgi - PHP Common Gateway Interface 'CGI' command
9

SYNOPSIS

11       php [options] [ -f ] file [[--] args...]
12
13       php [options] -r code [[--] args...]
14
15       php [options] [-B code] -R code [-E code] [[--] args...]
16
17       php [options] [-B code] -F file [-E code] [[--] args...]
18
19       php [options] -- [ args...]
20
21       php [options] -a
22
23       php [options] -S addr:port [-t docroot]
24

DESCRIPTION

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 embedded 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

OPTIONS

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       --global name
95       -g name        Make variable name global in script.
96
97       --help
98       -h             This help
99
100       --hide-args
101       -H             Hide script name (file) and  parameters  (args...)  from
102                      external  tools.  For  example  you may want to use this
103                      when a php script is started as a daemon and the command
104                      line contains sensitive data such as passwords.
105
106       --info
107       -i             PHP information and configuration
108
109       --syntax-check
110       -l             Syntax check only (lint)
111
112       --modules
113       -m             Show compiled in modules
114
115       --run code
116       -r code        Run PHP code without using script tags '<?..?>'
117
118       --process-begin code
119       -B code        Run PHP code before processing input lines
120
121       --process-code code
122       -R code        Run PHP code for every input line
123
124       --process-file file
125       -F file        Parse and execute file for every input line
126
127       --process-end code
128       -E code        Run PHP code after processing all input lines
129
130       --syntax-highlight
131       -s             Output HTML syntax highlighted source
132
133       --server addr:port
134       -S addr:port   Start  embedded Webserver on the given local address and
135                      port
136
137       --docroot docroot
138       -t docroot     Specify the document root to be used by the embedded web
139                      server
140
141       --version
142       -v             Version number
143
144       --stripped
145       -w             Output source with stripped comments and whitespace
146
147       --zend-extension file
148       -z file        Load Zend extension file
149
150       args...        Arguments  passed  to  script.  Use '--' args when first
151                      argument starts with '-' or script is read from stdin
152
153       --rfunction    name
154       --rf           name Shows information about function name
155
156       --rclass       name
157       --rc           name Shows information about class name
158
159       --rextension   name
160       --re           name Shows information about extension name
161
162       --rzendextension
163                      name
164       --rz           name Shows information about Zend extension name
165
166       --rextinfo     name
167       --ri           name Shows configuration for extension name
168
169       --ini          Show configuration file names
170

FILES

172       php-cli.ini    The configuration file for the CLI version of PHP.
173
174       php.ini        The standard configuration file will only be  used  when
175                      php-cli.ini cannot be found.
176

EXAMPLES

178       php -r 'echo "Hello World\n";'
179            This command simply writes the text "Hello World" to standard out.
180
181       php -r 'print_r(gd_info());'
182            This  shows  the  configuration  of your gd extension. You can use
183            this to easily check which image formats you can use. If you  have
184            any dynamic modules you may want to use the same ini file that php
185            uses when executed from your webserver. There are more  extensions
186            which have such a function. For dba use:
187            php -r 'print_r(dba_handlers(1));'
188
189       php -R 'echo strip_tags($argn)."\n";'
190            This PHP command strips off the HTML tags line by line and outputs
191            the result. To see how it works you can first look at the  follow‐
192            ing PHP command ´php -d html_errors=1 -i´ which uses PHP to output
193            HTML formatted configuration  information.  If  you  then  combine
194            those two ´php ...|php ...´ you'll see what happens.
195
196       php -E 'echo "Lines: $argi\n";'
197            Using this PHP command you can count the lines being input.
198
199       php -R '@$l+=count(file($argn));' -E 'echo "Lines:$l\n";'
200            In  this  example  PHP  expects  each  input line being a file. It
201            counts all lines of the files specified by  each  input  line  and
202            shows the summarized result.  You may combine this with tools like
203            find and change the php scriptlet.
204
205       php -R 'echo "$argn\n"; fgets(STDIN);'
206            Since you have access to STDIN from within -B -R -F and -E you can
207            skip  certain  input  lines  with your code. But note that in such
208            cases $argi only counts the lines being processed by  php  itself.
209            Having read this you will guess what the above program does: skip‐
210            ping every second input line.
211

TIPS

213       You can use a shebang line to automatically invoke  php  from  scripts.
214       Only  the  CLI  version  of  PHP will ignore such a first line as shown
215       below:
216
217              #!/bin/php
218              <?php
219               // your script
220              ?>
221

SEE ALSO

223       For a more or less complete description of PHP look here:
224       http://www.php.net/manual/
225

BUGS

227       You can view the list of known bugs or report any new bug you found at:
228       http://bugs.php.net
229

AUTHORS

231       The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Ler‐
232       dorf,  Sam  Ruby,  Sascha  Schumann, Zeev Suraski, Jim Winstead, Andrei
233       Zmievski.
234
235       Additional work for the CLI sapi was done by  Edin  Kadribasic,  Marcus
236       Boerger and Johannes Schlueter.
237
238       A List of active developers can be found here:
239       http://www.php.net/credits.php
240
241       And last but not least PHP was developed with the help of a huge amount
242       of contributors all around the world.
243

VERSION INFORMATION

245       This manpage describes php, version 5.4.16.
246
248       Copyright © 1997-2013 The PHP Group
249
250       This source file is subject to version 3.01 of the PHP license, that is
251       bundled with this package in the file LICENSE, and is available through
252       the world-wide-web at the following url:
253       http://www.php.net/license/3_01.txt
254
255       If you did not receive a copy of the PHP  license  and  are  unable  to
256       obtain   it   through   the  world-wide-web,  please  send  a  note  to
257       license@php.net so we can mail you a copy immediately.
258
259
260
261The PHP Group                        2013                               PHP(1)
Impressum