为什么这个功能不能正常工作 [英] Why this function not working as excepted

查看:63
本文介绍了为什么这个功能不能正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经工作了好几个小时才能解决这个问题,当我第一次执行这个代码时,一切都还可以,但第二次没有任何显示。然后我意识到,如果我等待20-25秒按预期执行我正在使用这种方式



whois(google,web.tr)



我没有遇到任何问题其他扩展(com,net)等等



我是什么尝试过:



I have been working for hours to get this works the problem is that when I first execute this code everything is ok but second time nothing displays. Then I realized that if I wait 20-25 seconds gets executed as expected I am using this way

whois("google","web.tr")

I dont get any problem the other extensions(com,net) so on

What I have tried:

function whois($domainName, $ext)
{
    $servers = array(
        "biz" => "whois.neulevel.biz",
        "com" => "whois.internic.net",
        "us" => "whois.nic.us",
        "info" => "whois.nic.info",
        "name" => "whois.nic.name",
        "net" => "whois.internic.net",
        "tv" => "whois.nic.tv",
        "ru" => "whois.ripn.net",
        "org" => "whois.pir.org",

        "com.tr" => "whois.nic.tr",
        "gen.tr" => "whois.nic.tr",
        "web.tr" => "whois.nic.tr",
        "k12.tr" => "whois.nic.tr",
        "org.tr" => "whois.nic.tr"
    );
    $serverName = trim($servers[$ext]);
    $tamAd=$domainName.".".$ext;
    $whois = array();




    $output = "";
    if (function_exists('curl_version')) {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $serverName);
        curl_setopt($curl, CURLOPT_PORT, 43);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_TIMEOUT, 5);
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $tamAd. "\r\n");
        $result = curl_exec($curl);




        curl_close($curl);
        print_r($result);
    } else {
        trigger_error('cURL is not found!');
        exit();
    }




}
whois("google","web.tr");

推荐答案

domainName,
domainName,


ext)
{
ext) {


servers =数组(
biz=>whois.neulevel.biz,
com=>whois.internic.net,
us=>whois .nic.us,
info=>whois.nic.info,
name=>whois.nic.name,
net= >whois.internic.net,
tv=>whois.nic.tv,
ru=>whois.ripn.net,
org=>whois.pir.org,

com.tr=>whois.nic.tr,
gen.tr=> whois.nic.tr,
web.tr=>whois.nic.tr,
k12.tr=>whois.nic.tr,
org.tr=>whois.nic.tr
);
servers = array( "biz" => "whois.neulevel.biz", "com" => "whois.internic.net", "us" => "whois.nic.us", "info" => "whois.nic.info", "name" => "whois.nic.name", "net" => "whois.internic.net", "tv" => "whois.nic.tv", "ru" => "whois.ripn.net", "org" => "whois.pir.org", "com.tr" => "whois.nic.tr", "gen.tr" => "whois.nic.tr", "web.tr" => "whois.nic.tr", "k12.tr" => "whois.nic.tr", "org.tr" => "whois.nic.tr" );


这篇关于为什么这个功能不能正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆