我偶然发现了<html>
<head>
<script>
function test(message) {
alert(message);
}
</script>
</head>
<body>
<button onclick ="window.external.Test('called from script')">
Call client code.
</button>
</body>
</html>
方法的错误结果。
测试网址:http://www.zakon.hr/z/199/Zakon-o-elektroni%C4%8Dkoj-trgovini
以下是对该网址的简单curl请求:
正如您在屏幕截图中看到的那样,200 OK代码成功响应。
但如果我将get_headers()
用于同一个网址,我会得到一个结果:
get_headers()
为什么?
答案 0 :(得分:1)
最后一项包含需要正确编码的UTF-8数据。这有效:
var_dump(get_headers('http://www.zakon.hr/z/199/' .
rawurlencode('Zakon-o-elektroničkoj-trgovini')
));
生成此输出:
array(11) {
[0] =>
string(15) "HTTP/1.1 200 OK"
[1] =>
string(73) "Set-Cookie: JSESSIONID=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA; Path=/; HttpOnly"
[2] =>
string(100) "Set-Cookie: AAAA=AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA; Expires=Wed, 09-Apr-2025 14:57:24 GMT; Path=/"
[3] =>
string(37) "Content-Type: text/html;charset=utf-8"
[4] =>
string(23) "Content-Language: en-US"
[5] =>
string(21) "Content-Length: 74205"
[6] =>
string(21) "Vary: Accept-Encoding"
[7] =>
string(35) "Date: Mon, 01 Jun 2015 14:57:24 GMT"
[8] =>
string(17) "Connection: close"
[9] =>
string(22) "Server: lighttpd/2.0.0"
[10] =>
string(43) "Set-Cookie: LBSERVERID=srv2-zakonhr; path=/"
}