You are here: Re: Test for PTR Record « PHP Programming Language « IT news, forums, messages
Re: Test for PTR Record

Posted by Kim Andrι Akerψ on 08/22/06 12:53

Luke - eat.lemons@gmail.com wrote:

> Rik wrote:
> > 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,
>
> I have it working now but thanks for the response! I see how your
> script works, didn't think of doing it that way!
>
> Ps. What does the (bool) do exactly (im new to php)

It's a type cast that forces the variable to be evaluated as a boolean.
More about type casting can be found here:
http://php.net/language.types.type-juggling#language.types.typecasting

--
Kim AndrΓ© AkerΓΈ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация