逐风整理了两种方式,大家可以自行参考/使用:
#方式一<BR>$ch = curl_init('http://www.gaodaima.com');<BR>curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<BR>curl_exec($ch);<BR>echo curl_getinfo($ch, CURLINFO_HTTP_CODE); // 200<BR>curl_close($ch);<BR>
方式二
print_r(<BR> get_headers('http://www.baidu.com')<BR>);<BR>#返回以下内容:<BR>/*<BR>Array <BR>( <BR>[0] => HTTP/1.1 200 OK <BR>[1] => Date: Sun, 04 May 2014 03:43:04 GMT <BR>[2] => Content-Type: text/html; charset=utf-<a style="color:transparent">、本文来源gao($daima.com搞@代@#码$网</a><big>搞gaodaima代码</big>8 <BR>[3] => Connection: Close <BR>[4] => Vary: Accept-Encoding <BR>[5] => Set-Cookie: BAIDUID=4977AF4FB1E9A5D13C79939E28D92161:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com <BR>[6] => Set-Cookie: BDSVRTM=0; path=/ <BR>[7] => Set-Cookie: H_PS_PSSID=4681_1465_5224_6023_4759_6018_6257_6313_6328_6269; path=/; domain=.baidu.com <BR>[8] => P3P: CP=" OTI DSP COR IVA OUR IND COM " <BR>[9] => Cache-Control: private <BR>[10] => Expires: Sun, 04 May 2014 03:42:09 GMT <BR>[11] => X-Powered-By: HPHP <BR>[12] => Server: BWS/1.1 <BR>[13] => BDPAGETYPE: 1 <BR>[14] => BDQID: 0x9acb602d00001922 <BR>[15] => BDUSERID: 0 <BR>) <BR>*/<BR>