我偶然发现了get_headers()
方法的错误结果。
测试网址:http ://www.zakon.hr/z/199/Zakon-o-elektroni%C4%8Dkoj-trgovini
这是对该 URL 的简单 curl 请求:
正如您在屏幕截图中看到的那样,成功响应 200 OK 代码。
但是,如果我使用get_headers()
相同的 URL,我会得到另一个结果:
var_dump(get_headers('http://www.zakon.hr/z/199/Zakon-o-elektroničkoj-trgovini'));
array(4) {
[0]=>
string(24) "HTTP/1.0 400 Bad request"
[1]=>
string(23) "Cache-Control: no-cache"
[2]=>
string(17) "Connection: close"
[3]=>
string(23) "Content-Type: text/html"
}
这是为什么?