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

NAME

6       php - PHP Command Line Interface 'CLI'
7

SYNOPSIS

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

DESCRIPTION

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

OPTIONS

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       --php-ini path|file
56       -c path|file   Look for php.ini file in the directory path or  use  the
57                      specified file
58
59       --no-php-ini
60       -n             No php.ini file will be used
61
62       --define foo[=bar]
63       -d foo[=bar]   Define INI entry foo with value bar
64
65       -e             Generate extended information for debugger/profiler
66
67       --file file
68       -f file        Parse and execute file
69
70       --global name
71       -g name        Make variable name global in script.
72
73       --help
74       -h             This help
75
76       --hide-args
77       -H             Hide  script  name  (file) and parameters (args...) from
78                      external tools. For example you may  want  to  use  this
79                      when a php script is started as a daemon and the command
80                      line contains sensitive data such as passwords.
81
82       --info
83       -i             PHP information and configuration
84
85       --syntax-check
86       -l             Syntax check only (lint)
87
88       --modules
89       -m             Show compiled in modules
90
91       --run code
92       -r code        Run PHP code without using script tags '<?..?>'
93
94       --process-begin code
95       -B code        Run PHP code before processing input lines
96
97       --process-code code
98       -R code        Run PHP code for every input line
99
100       --process-file file
101       -F file        Parse and execute file for every input line
102
103       --process-end code
104       -E code        Run PHP code after processing all input lines
105
106       --syntax-highlight
107       -s             Display colour syntax highlighted source
108
109       --version
110       -v             Version number
111
112       --stripped
113       -w             Display source with stripped comments and whitespace
114
115       --zend-extension file
116       -z file        Load Zend extension file
117
118       args...        Arguments passed to script. Use  '--'  args  when  first
119                      argument starts with '-' or script is read from stdin
120
121       --rfunction    name
122       --rf           name Shows information about function name
123
124       --rclass       name
125       --rc           name Shows information about class name
126
127       --rextension   name
128       --re           name Shows information about extension name
129
130       --rextinfo     name
131       --ri           name Shows configuration for extension name
132

FILES

134       php-cli.ini    The configuration file for the CLI version of PHP.
135
136       php.ini        The  standard  configuration file will only be used when
137                      php-cli.ini cannot be found.
138

EXAMPLES

140       php -r 'echo "Hello World\n";'
141            This command simply writes the text "Hello World" to standard out.
142
143       php -r 'print_r(gd_info());'
144            This shows the configuration of your gd  extension.  You  can  use
145            this  to easily check which image formats you can use. If you have
146            any dynamic modules you may want to use the same ini file that php
147            uses  when executed from your webserver. There are more extensions
148            which have such a function. For dba use:
149            php -r 'print_r(dba_handlers(1));'
150
151       php -R 'echo strip_tags($argn)."\n";'
152            This PHP command strips off the HTML tags line by line and outputs
153            the  result. To see how it works you can first look at the follow‐
154            ing PHP command ´php -d html_errors=1 -i´ which uses PHP to output
155            HTML  formatted  configuration  information.  If  you then combine
156            those two ´php ...|php ...´ you'll see what happens.
157
158       php -E 'echo "Lines: $argi\n";'
159            Using this PHP command you can count the lines being input.
160
161       php -R '@$l+=count(file($argn));' -E 'echo "Lines:$l\n";'
162            In this example PHP expects each input  line  beeing  a  file.  It
163            counts  all  lines  of  the files specified by each input line and
164            shows the summarized result.  You may combine this with tools like
165            find and change the php scriptlet.
166
167       php -R 'echo "$argn\n"; fgets(STDIN);'
168            Since you have access to STDIN from within -B -R -F and -E you can
169            skip certain input lines with your code. But  note  that  in  such
170            cases  $argi  only counts the lines being processed by php itself.
171            Having read this you will guess what the above program does: skip‐
172            ping every second input line.
173

TIPS

175       You  can  use  a shebang line to automatically invoke php from scripts.
176       Only the CLI version of PHP will ignore such  a  first  line  as  shown
177       below:
178
179              #!/bin/php
180              <?php
181               // your script
182              ?>
183

SEE ALSO

185       For a more or less complete description of PHP look here:
186       http://www.php.net/manual/
187
188       A nice introduction to PHP by Stig Bakken can be found here:
189       http://www.zend.com/zend/art/intro.php
190

BUGS

192       You can view the list of known bugs or report any new bug you found at:
193       http://bugs.php.net
194

AUTHORS

196       The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Ler‐
197       dorf, Sam Ruby, Sascha Schumann, Zeev  Suraski,  Jim  Winstead,  Andrei
198       Zmievski.
199
200       Additional  work  for  the CLI sapi was done by Edin Kadribasic, Marcus
201       Boerger and Johannes Schlueter.
202
203       A List of active developers can be found here:
204       http://www.php.net/credits.php
205
206       And last but not least PHP was developed with the help of a huge amount
207       of contributors all around the world.
208

VERSION INFORMATION

210       This manpage describes php, version 5.2.6.
211
213       Copyright © 1997-2008 The PHP Group
214
215       This source file is subject to version 3.01 of the PHP license, that is
216       bundled with this package in the file LICENSE, and is available through
217       the world-wide-web at the following url:
218       http://www.php.net/license/3_01.txt
219
220       If  you  did  not  receive  a copy of the PHP license and are unable to
221       obtain  it  through  the  world-wide-web,  please  send   a   note   to
222       license@php.net so we can mail you a copy immediately.
223
224
225
226The PHP Group                        2008                               PHP(1)
Impressum