SL8R.co.uk - Code Zone

Code, Code and Code

SL8R.co.uk - Code Zone header image 2

PHP: Checking a DNS entry

May 22nd, 2008 · 1 Comment

It is often useful to check that a given domain name or host is valid, this can be achieved using the checkdnserr() command, as in the following example:

$hostname = "www.domain.com.";
$dnstype = "MX";
$bValid = checkdnserr($hostname,$dnstype);

If using a DNS name then ensure the domain ends with the root domain qualifier (the “.”)

If the $dnstype is omitted or left blank the default check will be for an MX (Mail Exchanger) record.

http://uk.php.net/checkdnsrr

Tags: Tip

1 response so far ↓

Leave a Comment