|
Posted by Rik on 08/22/06 12:36
eat.lemons@gmail.com wrote:
> Hi all,
>
> I need to test a IP for a PTR record and display the outcome.
>
> The problem i have is i need to test with 2 vars.
>
> $host = the ip
> $hostmask = the hostmask
>
> How do i use 2 vars in one function so i can call it like:
>
> test_ptr($host, $hostmask)
>
> Ive tested this but cant seem to get it to work.
>
> code below. Thanks in advance
>
> function test_ptr($host) {
> if (strlen(gethostbyaddr($host))==
> strlen(gethostbyname("$hostmask"))) {
> $emsg = " !!Couldent find PTR Record!!";
> }
> }
I'm not exactly sure what you're trying to do, but probably:
function test_ptr($ip,$hostname){
return (trim($ip)==trim(gethostbyname($hostname)));
}
Or, alternatively, since you seem to want an error message:
function test_ptr($ip,$hostname){
$return = (bool)(trim($ip)==trim(gethostbyname($hostname)));
if(!$return) trigger_error("{$hostname}'s ip is not {$ip}");
return $return;
}
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|