【发布时间】:2018-08-29 14:37:39
【问题描述】:
似乎默认情况下,PHP-CLI 现在仅在安静模式下运行,而不是要求用户通过 -q 或 --no-header。
例如,如果phptest.php 如下:
<?php header("Location: http://www.something.com"); ?>
我们可以使用 cURL 和 Apache 服务器请求它,结果如下:
$ curl -I "http://localhost/phptest.php"
HTTP/1.1 302 Found
Date: Tue, 20 Mar 2018 16:47:48 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.24
Location: http://www.something.com
Content-Type: text/html
但是如果我们通过 PHP-CLI 请求,我们什么也得不到:
$ php /var/www/phptest.php
那么,我的问题是如何让 PHP-CLI 也返回标头?如果不可能,有哪些替代方案(没有 cURLing 或 wgeting 它)?
【问题讨论】:
标签: php