php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39074 Problem with getHostByAddr
Submitted: 2006-10-07 09:23 UTC Modified: 2006-10-19 07:47 UTC
From: webmaster at smiliz dot info Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2.0RC5 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: webmaster at smiliz dot info
New email:
PHP Version: OS:

 

 [2006-10-07 09:23 UTC] webmaster at smiliz dot info
Description:
------------
OS : windows XP
Apache 2.2.3
PHP 5.2 rc5

getHostByAddr not return host and the performance as reduced  !

Reproduce code:
---------------
$fai = @getHostByAddr($_SERVER['REMOTE_ADDR']);
$fai = str_replace(' ','',$fai); 
$fai = strtolower($fai); 
$rep = explode('.', $fai);
if ( $rep[0] == "" ) {
    $reponse = "Inconnu";
}elseif ( $rep[1] == "" ){
 $reponse = ucwords($rep[0]);
}else{
 $reponse = ucwords($rep[count($rep)-2]).".".strtolower($rep[count($rep)-1]);
}
echo $reponse;


echo var_dump(getHostByAddr($_SERVER['REMOTE_ADDR']));
=> result : string(13) "xxx.xxx.xxx.xxx" 

Expected result:
----------------
wanadoo.fr

Actual result:
--------------
xxx.xxx


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-07 09:40 UTC] tony2001@php.net
Please makre sure you have a reachable working DNS server set up and give it a try with PHP CLI.
 [2006-10-07 13:34 UTC] webmaster at smiliz dot info
I'm verify working dns on my server computer -> OK !
I'm try with php CLI -> getHostByAddr not return host !
But in localhost, getHostByAddr return localhost.
 [2006-10-07 18:09 UTC] tony2001@php.net
Does `nslookup <ip addr>` work for you?
 [2006-10-07 18:35 UTC] webmaster at smiliz dot info
yes is work.
nslookup xxx.xxx.xxx.xxx

return =>
Serveur : xxxxxxxxxx
Address: xxx.xxx.xxx.xxx
etc...
 [2006-10-07 18:46 UTC] webmaster at smiliz dot info
I'm test PHP 5.2RC5 whith apache 1.3.37.
getHostByAddr return correctly Host => wanadoo.fr

But, i'm test PHP 5.2 RC5 with Apache 2.2.3 on the same server and => getHostByAddr not return host
 [2006-10-18 20:53 UTC] tony2001@php.net
Can't reproduce.
C:\php -r "var_dump(gethostbyname('wanadoo.fr'));"
string(15) "193.252.122.103"

C:\php -r "var_dump(gethostbyaddr('193.252.122.103'));"
string(25) "hpwoo.wanadooportails.com"

 [2006-10-19 04:56 UTC] webmaster at smiliz dot info
I'm test PHP Version 5.2.0RC6-dev
And this code running :
<?
$SERVER_NAME = $_SERVER["SERVER_NAME"];
$IP = gethostbyname($SERVER_NAME);
$server = gethostbyaddr($IP);
echo "<br>Server IP: $IP";
echo "<br>Server Name: $server"; 
?>

gethostbyaddr return expected result.

Thank you.
 [2006-10-19 07:47 UTC] tony2001@php.net
.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 20:01:33 2025 UTC