해당 URL이 정상인지 체크

PHP 2020. 4. 21. 16:56

$url = "https://blog.naver.com/";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
echo $info['http_code'] == 200 ? "정상" : "비정상";

댓글 0