blog » PHP » 使用cgi作为php运行的命令需要注意的

使用cgi作为php运行的命令需要注意的

使用php cgi而非cli作为PHP命令行的解释命令时,需要注意部分设置。根据手册的说明,使用cli时,默认有了如下的支持:

Overridden php.ini directives
Directive CLI SAPIdefault value Comment
html_errors FALSE It can be quite hard to read the error message in your shell when it’s cluttered with all those meaningless HTML tags, therefore this directive defaults to FALSE.
implicit_flush TRUE It is desired that any output coming from print()echo() and friends is immediately written to the output and not cached in any buffer. You still can use output buffering if you want to defer or manipulate standard output.
max_execution_time 0 (unlimited) Due to endless possibilities of using PHP in shell environments, the maximum execution time has been set to unlimited. Whereas applications written for the web are often executed very quickly, shell application tend to have a much longer execution time.
register_argc_argv TRUE Because this setting is TRUE you will always have access to argc (number of arguments passed to the application) and argv(array of the actual arguments) in the CLI SAPI.

The PHP variables $argc and $argv are registered and filled in with the appropriate values when using the CLI SAPI. You can also go through $_SERVER or. Example: $_SERVER['argv']

output_buffering FALSE Altough the php.ini setting is hardcoded to FALSE the Output buffering functions are available.
max_input_time FALSE The PHP CLI doesn’t not support GET, POST or file uploads.

那么在cgi时候记得做好相应设置,比如我就忘了设register_argc_argv为on了,造成找不到argv参数;output_buffering没设成off,命令行就没法直接动态的输出了。。。。

相关文章:


RSS 2.0 | leave a response | trackback

发表评论