Home >Backend Development >PHP Tutorial >PHP uses curl to determine whether a remote file exists_PHP tutorial

PHP uses curl to determine whether a remote file exists_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-21 14:58:17825browse

PHP uses curl to determine whether the remote file exists. Please see the code below:

//Judge remote files
function check_remote_file_exists($url)
{
$curl = curl_init($url);
//Do not retrieve data
curl_setopt($curl, CURLOPT_NOBODY, true);
// Send request
$result = curl_exec($curl);
$found = false;
// If the request is not sent, it fails
if ($result ! == false) {
// Check again whether the http response code is 200
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($statusCode == 200) {
$found = true;
}
}
curl_close($curl);

return $found;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/363880.htmlTechArticlePHP uses curl to determine whether the remote file exists. Please see the code below: //Judge the remote file function check_remote_file_exists($ url) { $curl = curl_init($url); // Do not retrieve data cu...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn