-a Run as interactive shell[交互式运行,示例如下] -c <path>|<file> Look for php.ini file in this directory[指定ini文件] -n No configuration (ini) files will be used[不使用ini文件配置] -d foo[=bar] Define INI entry foo with value 'bar'[设置ini配置的键值,示例如下] -e Generate extended information for debugger/profiler[为调试工具生成调试信息,试了下没看见生成的信息,估计需要配合xdebug/phpdebugbar使用] -f <file> Parse and execute <file>.[指定要执行的文件] -h This help[获取所有命令列表] -i PHP information[获取php.ini信息] -l Syntax check only (lint)[对php文件进行语法检测] -m Show compiled in modules[获取已经安装的扩展名称列表] -r <code> Run PHP <code> without using script tags <?..?>[执行一段php代码不需要声明开头和结束<?php>] -B <begin_code> Run PHP <begin_code> before processing input lines[输入前执行的代码] -R <code> Run PHP <code> for every input line[执行此代码在每次输入的时候] -F <file> Parse and execute <file> for every input line[执行此文件在每次输入的时候] -E <end_code> Run PHP <end_code> after processing all input lines[执行此代码在所有的输入之后] -H Hide any passed arguments from external tools.[没太理解,看意思是对外部工具隐藏传递的参数] -S <addr>:<port> Run with built-in web server.[启动内置的web server,例如php -S localhost:9998] -t <docroot> Specify document root <docroot> for built-in web server.[和上面的php -S 命令搭配使用,指定web server的根目录,示例如下] -s Output HTML syntax highlighted source.[输出脚本文件源码为html,并且语法高亮,示例如下] -v Version number[获取php的版本信息] -w Output source with stripped comments and whitespace.[去除脚本文件源码的注释和空格,然后输出,示例如下] -z <file> Load Zend extension <file>.[加载一个zend扩展]
args... Arguments passed to script. Use -- args when first argument starts with - or script is read from stdin[额外参数,脚本中可以通过$argv获取,示例如下]
--ini Show configuration file names[展示加载的.ini文件的基本信息(路径/名称),示例如下]
--rf <name> Show information about function <name>.[输出一个函数的信息] --rc <name> Show information about class <name>.[输出一个类的信息] --re <name> Show information about extension <name>.[输出一个扩展的信息] --rz <name> Show information about Zend extension <name>.[输出一个zend扩展的信息] --ri <name> Show configuration for extension <name>.[输出一个扩展的配置信息]
(tigerb) ➜ test php -w test.php <?php var_dump($argv);%
php -S & php -t
php -S & php -t搭配使用:
(tigerb) ➜ test php -S localhost:9998 -t ./ PHP 7.2.6 Development Server started at Sat Oct 20 23:09:17 2018 Listening on http://localhost:9998 Document root is /Users/tigerb/Documents/code/test Press Ctrl-C to quit. [Sat Oct 20 23:09:20 2018] PHP Notice: Undefined variable: argv in /Users/tigerb/Documents/code/test/test.php on line 4 [Sat Oct 20 23:09:20 2018] ::1:51244 [200]: /test.php
--------
(tigerb) ➜ test php -S localhost:9998 -t / PHP 7.2.6 Development Server started at Sat Oct 20 23:09:38 2018 Listening on http://localhost:9998 Document root is / Press Ctrl-C to quit. [Sat Oct 20 23:09:43 2018] ::1:51261 [404]: /test.php - No such file or directory
– args
下面的示例很好的解释了Use -- args when first argument starts with - or script is read from stdin这句话: