嗯......簡單的代碼:
$response = file_get_contents("http://www.projecthoneypot.org/ip_127.0.0.1");
$match = preg_match("/don't have data on this IP currently/i", $response);
if($match) {
echo "No Date";
} else {
echo "Data Was Found";
}
或用捲髮:
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => 'http://www.projecthoneypot.org/ip_127.0.0.1',
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,
));
$response = curl_exec($ch);
curl_close($ch);
$match = preg_match("/don't have data on this IP currently/i", $response);
if($match) {
echo "No Date";
} else {
echo "Data Was Found";
}
和獲取日期?什麼約會? –
那麼'fsockopen'會是創建HTTP請求的最糟糕的方式。請使用[curl](http://www.php.net/manual/en/function.curl-exec.php)或['file_get_contents'](http://ch2.php.net/manual/en/function .file-GET-contents.php)。後者需要啓用'allow_url_fopen'。 – vstm
Jan Dragsbaek只需一分鐘,我會改進Q.thanks – Maroman