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.

387 lines
8.5 KiB

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