当我从操作系统命令提示符运行我的php-cgi
可执行文件时,它还将内容类型和PHP版本作为stdout包含发送回来。但是,在php.exe中,这在Windows中是不可见的。
命令:php-cgi index.php
代码:
<?php
header('Content-Type: application/json');
header('Content-Type: text/html; charset=utf-8');
echo json_encode(array('$_SERVER' => $_SERVER));
?>
PHP-CGI输出:
X-Powered-By: PHP/8.1.3
Content-Type: text/html; charset=utf-8
{"$_SERVER":{"ALLUSERSPROFILE":"C:\ProgramData","APPDATA"......}
PHP输出:
{"$_SERVER":{"ALLUSERSPROFILE":"C:\ProgramData","APPDATA"......}
在使用php-cgi时,有没有一种方法可以避免powered by和默认内容类型被破坏?有背景吗?我在php.ini 中没有找到任何
php-cgi -q index.php
-q Quiet-mode. Suppress HTTP Header output.
为了抑制";X-Powered-Bby:PHP/8.1.3";
php-cgi -d expose_php=off index.php