Zhufeng has compiled two methods that you can refer to/use by yourself:
Copy code The code is as follows:
#Method 1
$ch = curl_init('http://www. jb51.net');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE); // 200
curl_close($ch );
Method 2
Copy code The code is as follows:
print_r(
get_headers('http://www.baidu.com' )
);
#Returns the following content:
/*
Array
(
[0] => HTTP/1.1 200 OK Date: Sun, 04 May 2014 03:43:04 GMT
[2] => Content-Type: text/html; charset=utf-8
[3] => Connection: Close
[4] => Vary: Accept-Encoding
[5] => Set-Cookie: BAIDUID=4977AF4FB1E9A5D13C79939E28D92161:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max- age=2147483647; path=/; domain=.baidu.com
[6] => Set-Cookie: BDSVRTM=0; path=/ 13_6328_6269 ; path=/; domain=.baidu.com
[8] => P3P: CP=" OTI DSP COR IVA OUR IND COM "
[9] => Cache-Control: private
[10] => Expires: Sun, 04 May 2014 03:42:09 GMT
[11] => X-Powered-By: HPHP
[12] => Server: BWS/1.1 [13] = & gt; bdpageType: 1
[14] = & gt; bdqid: 0x9acb602d00001922
[15] = & gt; bduserid: 0
)
*/
http://www.bkjia.com/PHPjc/767605.html
www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/767605.htmlTechArticleZhufeng has compiled two methods. You can refer to/use them yourself: Copy the code as follows: #method1$ ch = curl_init('http://www.jb51.net'); curl_setopt($ch, CURLOPT_RETURNTRANSF...