当我从OS命令提示符运行我的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输出:
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时,由默认内容类型驱动吗?有什么背景吗?我在php.ini里没有找到
发布于 2022-04-03 12:59:44
php-cgi -q index.php
-q Quiet-mode. Suppress HTTP Header output.
压制“X驱动-By: PHP/8.1.3”
php-cgi -d expose_php=off index.php
https://stackoverflow.com/questions/71725680
复制相似问题