我需要获取一个页面的内容,该页面总是发送一个Content-Length: 0
标题,但是页面永远不会为空。
只是返回一个空file_get_contents(url)
字符串。
页面返回的整个标题是:
HTTP/1.1 200 OK
X-Powered-By: PHP/5.3.10
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Last-Modified: Sat, 18 Feb 2012 18:14:59 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Pragma: no-cache
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Date: Sat, 18 Feb 2012 18:14:59 GMT
Server: lighttpd
是否可以使用 file_get_contents 并忽略标题,还是我需要使用 curl?
编辑
get_headers(url)
输出(使用print_r
):
Array
(
[0] => HTTP/1.0 200 OK
[1] => X-Powered-By: PHP/5.3.10
[2] => Content-type: text/html
[3] => Content-Length: 0
[4] => Connection: close
[5] => Date: Sat, 18 Feb 2012 22:39:52 GMT
[6] => Server: lighttpd
)