<?php $result = whois('www.zoe725.cn'); $xml = simplexml_load_string($result); $code = is_register($xml->original); if ($code == 0) { echo '域名可以注冊'; } else if ($code == 1) { echo '‘域名已經注冊’'; } else { echo '‘域名參數傳輸錯誤’'; } function whois($domain) { // 創建一個新cURL資源 $ch = curl_init(); // 設置URL和相應的選項 curl_setopt($ch, CURLOPT_URL, 'http://panda.www.net.cn/cgi-bin/check.cgi'); curl_setopt($ch, CURLOPT_HEADER, 0); //將curl_exec()獲取的信息以文件流的形式返回,而不是直接輸出 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //POST請求 curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'area_domain=' . trim($domain) ); //執行cURL會話 $response = curl_exec($ch); // 關閉cURL資源,并且釋放系統資源 curl_close($ch); return $response; } function is_register($res) { $code = substr($res, 0, 3); if ($code == '210') { return 0; } else if ($code == '211') { return 1; } else { return 2; } }
轉載請注明出處 AE博客|墨淵 ? PHP檢測域名是否已被注冊
發表評論