|
Posted by Sagari on 01/28/07 02:43
Three objections:
1. Not all the registered domain names have valid 'A' record. In that
case, gethostbyname() won't return anything meaningful for registered
domain. You'll have to address WHOIS database directly and that isn't
an easy and quick trick, generally.
2. Domain names check might be required to register that domain.
Again, gethostbyname(0 won't return anything useful.
3. In case the corresponding nameservers are unreachable at the
moment, gethostbyname() won't return anything valid
I only wished to say that gethostbyname() doesn't fit all the cases
and, in general, it makes validation significantly slower.
Best wishes,
Konstantin
> This check will allow for a domain like 'foobar.quux.quuux.' even though
> it is obviously not a real domain though. To check that it's a real,
> registered domain name, which points to a real IP address, we can use
> gethostbyname():
>
> // Firstly, do all the above stuff to make sure it it syntactically
> // correct. No point wasting network resources calling gethostbyname()
> // for a domain that is obviously invalid. Now:
>
> $domain_ok = $domain_ok && !empty(gethostbyname($domain));
>
> // Now $domain_ok is TRUE iff $domain is an Internet host. Yay!
>
> --
> Toby A Inkster BSc (Hons) ARCS
> Contact Me ~http://tobyinkster.co.uk/contact
Navigation:
[Reply to this message]
|