note 9775 modified in function.gethostbyaddr by nlopess
| From: | nlopess@php.net | Date: | Sat, 30 Apr 2005 18:27:24 +0000 |
| Subject: | note 9775 modified in function.gethostbyaddr by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-88795@lists.php.net to get a copy of this message | ||
This is a really usefull function.. I ussualy use it to know the name of the country that the host
has.. (.pt, .es, .uk, etc)..
here is a litle idea of what one can do with this..
I get the $ipa with the remote_addr function..
<?php
$host = gethostbyaddr($ipa);
$at = $host
$hostdot = ".";
$result = strrchr($at, $hostdot);
echo "The country is $result";
?>
Of course, if a .com or .org or .net domain name (tld) it won't be a country.. but you can work
that out with and if or case statements..
and of course, I can be totally mistaken ;P
--was--
This is a really usefull function.. I ussualy use it to know the name of the country that the host
has.. (.pt, .es, .uk, etc)..
here is a litle idea of what one can do with this..
I get the $ipa with the remote_addr function..
<?
$host = gethostbyaddr($ipa);
$at = $host
$hostdot = ".";
$result = strrchr($at, $hostdot);
echo "The country is $result";
?>
Of course, if a .com or .org or .net domain name (tld) it won't be a country.. but you can work
that out with and if or case statements..
and of course, I can be totally mistaken ;P
http://php.net/manual/en/function.gethostbyaddr.php