从 PHP 4 移植到 PHP 5
在线手册:中文 英文
PHP手册

CLI 和 CGI

PHP 5 中对 CLI 和 CGI 文件名作了些改变。PHP 5 中,CGI 版本被改名为 php-cgi.exe(以前是 php.exe),现在主目录中的是 CLI 版本(之前是 cli/php.exe)。

PHP 5 中引进了一种新模式:php-win.exe。这和 CLI 版本相同,只除了 php-win 不输出任何内容,因此不会提供控制台(屏幕上不会闪过“dos 窗口”)。此行为类似 php-gtk。

PHP 5 中,CLI 版本总会产生全局变量 $argv$argc 而不管 php.ini 是怎么设的。即使将 register_argc_argv 设为 off 也不影响 CLI。

参见命令行模式


从 PHP 4 移植到 PHP 5
在线手册:中文 英文
PHP手册
PHP手册 - N: CLI 和 CGI

用户评论:

shoebappa at gmail dot com (12-Mar-2008 08:41)

I pulled my hair out for 10 hours trying to figure out why my CGI Wrappers would spit out the shell script and not run the code.

From: http://ubuntuforums.org/showthread.php?t=341164&highlight=apache+php

"PHP4 needs a specific configuration so that it won't try to execute the starter script.
Edit /etc/php4/cgi/php.ini, search for cgi.fix_pathinfo and set it to 1.

If you don't do this, PHP5 will work fine (it has cgi.fix_pathinfo compiled right in), but PHP4 will simply output the starter script. (You can even put <?php phpinfo (); ?> inside the starter script and will see the PHP information.)"