2009-09-08 129 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