<?php
function checkRemoteResourceAvailability($target_url) {
$ch = curl_init($target_url);
curl_setopt($ch, CURLOPT_NOBODY, true);
$status = curl_exec($ch) !== false && curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200;
curl_close($ch);
return $status;
}
echo checkRemoteResourceAvailability('http://tw.yahoo.com/favicon.ico') ? "ok" : "not available";
沒有留言:
張貼留言