php static function isUrlExist url ch curl_init url curl_setopt ch CUR

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<?php
static function isUrlExist($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($code == 200){
$status = true;
}else{
$status = false;
}
curl_close($ch);
return $status;
}
$url = 'http://pictures.playboy.com/assets/content/photo/gallery/standard/201408/16290/thumbs/200x135/standard_thumb.jpg';
echo isUrlExist($url);