php 下令參數

來源:互聯網
上載者:User
php 命令參數
http://www.php.net/manual/zh/features.commandline.php

-f --file 解析並運行 -f 選項給定的檔案名稱。該參數為選擇性參數,可以省略,僅指明需要啟動並執行檔案名稱即可。



以下是 PHP 二進位檔案(即 php.exe 程式)提供的命令列模式的選項參數,您隨時可以通過 PHP -h 命令來查詢這些參數。


Usage: php [options] [-f] [args...]

php [options] -r DE>[args...] DE>

php [options] [-- args...]

-s Display colour syntax highlighted source.

-w Display source with stripped comments and whitespace.

-f Parse .

-v Version number

-c | Look for php.ini file in this directory

-a Run interactively

-d foo[=bar] Define INI entry foo with value 'bar'

-e Generate extended information for debugger/profiler

-z Load Zend extension .

-l Syntax check only (lint)

-m Show compiled in modules

-i PHP information

-r DE>Run PHP DE>without using script tags DE>DE>

-h This help


args... Arguments passed to script. Use -- args when first argument

starts with - or script is read from stdin


CLI SAPI 模組有以下三種不同的方法來擷取您要啟動並執行 PHP 代碼:


1.


讓 PHP 運行指定檔案。


php my_script.php


php -f my_script.php


以上兩種方法(使用或不使用 -f 參數)都能夠運行給定的 my_script.php 檔案。您可以選擇任何檔案來運行,您指定的 PHP 指令碼並非必須要以 .php 為副檔名,它們可以有任意的檔案名稱和副檔名。

2.


在命令列直接運行 PHP 代碼。


php -r 'print_r(get_defined_constants());'


在使用這種方法時,請您注意外殼變數的替代及引號的使用。


注: 請仔細閱讀以上範例,在運行代碼時沒有開始和結束的標記符!加上 -r 參數後,這些標記符是不需要的,加上它們會導致語法錯誤。


3.


通過標準輸入(stdin)提供需要啟動並執行 PHP 代碼。


以上用法給我們提供了非常強大的功能,使得我們可以如下範例所示,動態地產生 PHP 代碼並通過命令列運行這些代碼:


$ some_application | some_filter | php | sort -u >final_output.txt


以上三種運行代碼的方法不能同時使用。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.