Use curl in PHP to obtain the HTTP status code

Source: Internet
Author: User
To use curl, You need to enable it in php. ini on the Windows server. Open php. ini and find extensionphp_curl.dll to remove the preceding comment. The implementation code is as follows: $ curlcurl_init (); $ urlwww.smdcn.net; curl_setopt ($ curl, CURLOPT_URL, $ url); Set URLcurl_se

To use curl, You need to enable it in php. ini on the Windows server. Open php. ini and find: extension = php_curl.dll. Remove the preceding comment. Implementation Code: $ curl = curl_init (); $ url = http://www.smdcn.net; curl_setopt ($ curl, CURLOPT_URL, $ url); // set URL curl_se

To use curl, you must enable it in php. ini> <on a Windows Server, open php. ini and find:
Extension = php_curl.dll
Remove the preceding annotations.

The implementation code is as follows:

$ Curl = curl_init ();
$ Url = 'HTTP: // www.smdcn.net ';
Curl_setopt ($ curl, CURLOPT_URL, $ url); // sets the URL
Curl_setopt ($ curl, CURLOPT_HEADER, 1); // get the Header
Curl_setopt ($ curl, CURLOPT_NOBODY, true); // We just need Head
Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1); // Save the data to a string. Don't output it to the screen.
$ Data = curl_exec ($ curl); // start execution ~
Echo curl_getinfo ($ curl, CURLINFO_HTTP_CODE); // I know the HTTPSTAT code ~
Curl_close ($ curl); // when used up, remember to turn it off.

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.