2009-09-08 51 views
4

運行我有一個PHP文件,需要在一個cronjob和它上面運行已參數通過cron

#!/usr/bin/php -q 

我知道的第一部分告訴服務器來解釋文件以下與PHP導致其不通過網絡服務器運行,但什麼是-q的?

另外,還有其他參數嗎?如果是這樣,我可以在哪裏閱讀更多關於它們

謝謝

回答

9

-q是指其中不顯示標題信息安靜模式。這現在默認開啓,但-q仍然支持向後兼容性。

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 as interactive shell 
    -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    Display colour syntax highlighted source. 
    -v    Version number 
    -w    Display 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>. 
    --ri <name>  Show configuration for extension <name>. 

php -l是我使用最多的一個。這是很好的,在編輯時,要能夠運行在一個文件快速語法檢查(在vim,:! php -l %

4

-q是相當模式的命令行選項。 PHP Site解釋了其他命令行選項(部分向下翻頁),但是-q現在是默認的,它在列表中沒有提及。

在這個頁面:

CLI由 默認啓動安靜模式,雖然--no-header參數保持兼容性,這樣就可以使用 舊的CGI腳本-q和 。

0
[email protected]:~$ php --help 
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 as interactive shell 
    -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    Display colour syntax highlighted source. 
    -v    Version number 
    -w    Display 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>. 
    --ri <name>  Show configuration for extension <name>. 
-1

其中一些信息here,但它並沒有列出-q參數。但是,該頁面還列出了有關如何從命令行獲取參數的示例。

0

大多數類Unix操作系統都附帶manpages(手冊頁),其中包含有關命令的文檔。

通過在終端呼叫

man php 

,PHP的手冊頁將被顯示在該終端。它包含可用的各種不同選項。這是一個html版本的輸出: http://linux.die.net/man/1/php