PHP implementation code to get HTTP status _php tutorial

Source: Internet
Author: User
Wind up two ways, we can refer to the use of:

Copy the Code code as follows:
#方式一
$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);


Way Two

Copy CodeThe code is as follows:
Print_r (
Get_headers (' http://www.baidu.com ')
);
#返回以下内容:
/*
Array
(
[0] = = http/1.1-OK
[1] = Date:sun, 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=/
[7] = = set-cookie:h_ps_pssid=4681_1465_5224_6023_4759_6018_6257_6313_6328_6269; path=/; Domain=.baidu.com
[8] = = p3p:cp= "OTI DSP COR IVA our IND COM"
[9] = Cache-control:private
[] = Expires:sun, 03:42:09 GMT
[One] = x-powered-by:hphp
[[] = server:bws/1.1
[+] = bdpagetype:1
[+] = bdqid:0x9acb602d00001922
[[] = bduserid:0
)
*/

http://www.bkjia.com/PHPjc/767605.html www.bkjia.com true http://www.bkjia.com/PHPjc/767605.html techarticle wind up two ways, you can refer to/use: Copy the code as follows: #方式一 $ch = curl_init (' http://www.jb51.net '); curl_setopt ($ch, Curlopt_ Returntransf ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.