dtdfj08626 2014-08-18 07:24 采纳率: 0%
浏览 152

为什么使用“gethostbyaddr”将IP地址转换为主机名但不起作用? [关闭]

I try to convert IP Address to Hostname by used "gethostbyaddr" but don't work. I use file.text that is log file to analyze which page that user used a lot or less. So I try to cut sentence that use array. This is my code.

$file=fopen("log.txt","r");             

while (!feof($file)) {
    $buffer = fgets($file, 4096);                    

    $text= explode(" ",$buffer,10);



    $text_2=@$text[1];  
    $ip=substr($text_2,1,11);       
    $ip2=gethostbyaddr($ip);

    echo"INSERT INTO `log` VALUES ('$ip2');"."<br>";        //Show results

    //echo"<br>";           //New line
}

fclose($file);                              

Thanks

  • 写回答

1条回答 默认 最新

  • dsvyc66464 2014-08-18 07:53
    关注

    that means gethostbyaddr failed.

    not because your input, find the explanation in php documentation

    http://php.net/manual/en/function.gethostbyaddr.php

    "Returns the host name on success, the unmodified ip_address on failure, or FALSE on malformed input."

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集