W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
PHP 二進(jìn)制文件可以隨時通過執(zhí)行帶 -h 參數(shù)的 PHP 命令獲取提供的命令行選項列表:
Usage: php [options] [-f] <file> [--] [args...]
php [options] -r <code> [--] [args...]
php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
php [options] -- [args...]
php [options] -a
-a Run interactively
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse and execute <file>.
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-r <code> Run PHP <code> without using script tags <?..?>
-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.
-t <docroot> Specify document root <docroot> for built-in web server.
-s Output HTML syntax highlighted source.
-v Version number
-w Output source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
args... Arguments passed to script. Use -- args when first argument
starts with - or script is read from stdin
--ini Show configuration file names
--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>.
--ri <name> Show configuration for extension <name>.
選項 | 長選項 | 說明 |
---|---|---|
-a | --interactive |
運行交互式 PHP。參閱交互式 shell 章節(jié)獲取更多信息。 |
-b | --bindpath |
外部 FASTCGI 服務(wù)器模式綁定路徑(僅 CGI 可用)。 |
-C | --no-chdir |
不改變腳本的目錄(僅 CGI 可用)。 |
-q | --no-header |
安靜模式。禁止輸出 HTTP 頭(僅 CGI 可用)。 |
-T | --timing |
測量腳本重復(fù) count 次的執(zhí)行時間(僅 CGI 可用)。 |
-c | --php-ini |
在指定目錄查找 php.ini 或者自定義
如果未指定此選項,php.ini 將在默認(rèn)位置搜索。 |
-n | --no-php-ini |
完全忽略 php.ini。 |
-d | --define |
允許設(shè)置 php.ini 中配置指令的值。語法是:
|
-e | --profile-info |
激活擴(kuò)展信息模式,用于調(diào)試/分析。 |
-f | --file |
解析并執(zhí)行指定文件。 -f 可選且可以忽略 —— 只需提供需要執(zhí)行的文件名就足夠。 |
-h and -? | --help and --usage | 輸出命令行選項列表并描述了這些選項的作用。 |
-i | --info | 調(diào)用 phpinfo() 并輸出結(jié)果。如果 PHP 不能正常工作,建議使用命令 php -i 查看在信息表輸出之前或者中間某個位置是否有錯誤消息。注意當(dāng)使用 CGI 模式時會輸出 HTML, 這會非常大。 |
-l | --syntax-check |
提供了僅對指定 PHP 代碼進(jìn)行語法檢查的便捷方法。 成功時將會在標(biāo)準(zhǔn)輸出中寫入 此選項不能發(fā)現(xiàn)像是函數(shù)未定義之類的核心錯誤(fatal errors)??梢允褂?nbsp;-f 測試核心錯誤(fatal errors)。
|
-m | --modules |
示例 #1 打印內(nèi)置(且已加載的) PHP 和 Zend 模塊
|
-r | --run |
允許在命令行內(nèi)直接執(zhí)行單行 PHP 代碼。 不需要加上 PHP 開始和結(jié)束標(biāo)識符(
|
-B | --process-begin |
處理 stdin 之前需要執(zhí)行的 PHP 代碼。 |
-R | --process-code |
對每個輸入行都執(zhí)行的 PHP 代碼。 此模式下有兩個特殊變量: $argn 和 $argi。 $argn 將包含 PHP 正在處理的行, $argi 將包含正在處理的行號。 |
-F | --process-file |
對每個輸入行都執(zhí)行的 PHP 文件。 |
-E | --process-end |
在處理完輸入后執(zhí)行的 PHP 代碼。 示例 #4 使用 -B 、 -R 、 -E 選項統(tǒng)計項目總行數(shù)。
|
-S | --server |
啟動 內(nèi)置 web 服務(wù)器. |
-t | --docroot | 為內(nèi)置 web 服務(wù)器指定文檔根目錄。 |
-s | --syntax-highlight 和 --syntax-highlighting |
為源代碼添加語法高亮顯示。 此選項將使用內(nèi)部機(jī)制解析文件并將生成的 HTML 高亮版本寫入到標(biāo)準(zhǔn)輸出。 注意它所做的只是生成一塊
|
-v | --version |
示例 #5 使用 -v 獲取 SAPI 的名稱以及 PHP 和 Zend 的版本號
|
-w | --strip |
顯示忽略注釋和空格后的源代碼。
|
-z | --zend-extension |
加載 Zend 擴(kuò)展。如果僅指定了文件名,PHP 將嘗試從當(dāng)前系統(tǒng)默認(rèn)函數(shù)庫中嘗試加載此擴(kuò)展 (例如在 Linux 上通常是 /etc/ld.so.conf)。 傳遞絕對路徑的文件名將不會使用系統(tǒng)庫搜索路徑。如果用相對路徑指定的文件名,則 PHP 僅試圖在當(dāng)前目錄的相對目錄加載擴(kuò)展庫。 |
--ini |
展示配置文件名和掃描目錄。 示例 #6
|
|
--rf | --rfunction |
展示指定函數(shù)或者類方法的有關(guān)信息(例如參數(shù)名稱和數(shù)量)。 如果 PHP 在編譯時啟用 Reflection 支持,該選項才可以使用。 示例 #7 基礎(chǔ)
|
--rc | --rclass |
展示指定類的有關(guān)信息(常量、屬性和方法的列表)。 如果 PHP 在編譯時啟用 Reflection 支持,該選項才可以使用。 示例 #8
|
--re | --rextension |
展示指定擴(kuò)展的有關(guān)信息(php.ini 選項、定義函數(shù)、常量和類的列表)。 如果 PHP 在編譯時啟用 Reflection 支持,該選項才可以使用。 示例 #9
|
--rz | --rzendextension |
展示指定 Zend 擴(kuò)展的配置信息(也可以通過 phpinfo()返回相同信息)。 |
--ri | --rextinfo |
展示指定擴(kuò)展的配置信息(也可以通過 phpinfo()返回相同信息)。 使用 “main” 作為擴(kuò)展名可以獲取到核心配置信息。 示例 #10
|
注意:選項 -rBRFEH、 --ini 、 --r[fcezi] 僅可以在 CLI 中使用。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: