Using curl in php to determine whether an image or page is complete in PHP is a good thing. curl can be used to determine whether a file or page can be opened, such as functioncheck_url ($ url) {$ chcurl_init (); curl_setopt ($ ch, CURLOPT_URL, $ url); curl_setopt ($ ch, CURLOPT_HEADE php uses curl to judge whether the image or page is complete
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.