3

如何使用 php get_headers 仅获取位置部分?

var_dump(get_headers('http://www.google.com',1));

这个回报:

array(12) { [0]=> string(18) "HTTP/1.0 302 Found" ["Location"]=> string(21) "http://www.google.it/" ... }

然后我用

echo (get_headers('http://www.google.com',1)["Location"];

错误:Parse error: syntax error, unexpected '['在这一echo

4

1 回答 1

10
$headers = get_headers('http://www.google.com',1);
echo $headers["Location"];
于 2011-10-29T07:58:09.927 回答