How does php determine whether a remote file exists? The method found by the author on the internet is as follows. Php checks whether the remote file has functionurl_exists ($ url) {$ handlecurl_init ($ url); if (false $ handle) {returnfalse;} curl_setopt ($ handle, CURLOPT_HEADER, how does fals php determine whether a remote file exists?
The method found by the author on the internet is as follows.
// Php determines whether a remote file exists
Function url_exists ($ url ){
$ Handle = curl_init ($ url );
If (false ===$ handle ){
Return false;
}
Curl_setopt ($ handle, CURLOPT_HEADER, false );
Curl_setopt ($ handle, CURLOPT_FAILONERROR, true );
Curl_setopt ($ handle, CURLOPT_NOBODY, true );
Curl_setopt ($ handle, CURLOPT_RETURNTRANSFER, false );
$ Connectable = curl_exec ($ handle );
// Http://www.scutephp.com/
Curl_close ($ handle );
Return $ connectable;
}