You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

395 lines
8.9 KiB

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