Check Image URL Exists Or Not WIth PHP
How To Image Or Any File Exists Or Not With PHP Language
For checking the URL is exists or not we can use curl request in PHP and we can use same approach in other programming languages also such as JavaScript.
So for PHP URL check code is below:
function is_url_exist($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$status = ($code == 200) ? true : false; // single liner if else
curl_close($ch);
return $status;
}
Thanks for reading this blog, I hope it will be helpful for you and please share your feedback in comments section.
Comments
Post a Comment