【发布时间】:2012-12-06 15:58:55
【问题描述】:
http://!@#$%^&*().com
这似乎是一个无效的 URL,实际上浏览器说它是一个无效的 URL。
但是当我通过 file_get_contents (XAMPP) 获取这个 URL 时,它给出了“500 Internal Server Error”的异常,因为这个 URL 不存在为什么我没有得到 404?
检查我正在使用的响应
$http_response_header
这是我的代码:
$url = "http://!@#$%^&*().com";
$contents = @file_get_contents($url);
print_r($http_response_header);
当我在另一台机器 (WAMP) 上运行相同的程序时,它会说 $http_response_header 是一个未定义的变量。
有人知道这里有什么问题吗?
【问题讨论】:
-
它会自动填充响应标头。它适用于其他有效的 URL 并返回正确的响应。 php.net/manual/en/reserved.variables.httpresponseheader.php
标签: php url file-get-contents