Use curl in PHP to determine whether the image or page is complete

Source: Internet
Author: User

Introduction: This is a detailed page in PHP that uses curl to determine whether an image or page is complete. It introduces PHP, curl, PHP, setopt, CH, header PHP uses curl to determine whether the image or page is complete related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 350530 'rolling = 'no'>
In PHP, curl is a good thing and can be used to determine whether a file or page can be opened. For example:

Function check_url ($ URL)

{

$ CH = curl_init ();

Curl_setopt ($ ch, curlopt_url, $ URL );

Curl_setopt ($ ch, curlopt_header, 1 );

Curl_setopt ($ ch, curlopt_returntransfer, 1 );

$ DATA = curl_exec ($ ch );

$ Headers = curl_getinfo ($ ch );

Curl_close ($ ch );

Return $ headers ['HTTP _ Code'];

}

$ Myurl = "http://www.XXX/XXX.JPG ";

$ Satus = check_url ($ myurl );

If ($ satus = '20140901 ')

Echo "its works ";

Else

Echo "Broken URL ";

We can see that this method uses curl to retrieve the status of the HTTP header.

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/350530.html pageno: 3

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.