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.

411 lines
8.0 KiB

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