note 22927 added to function.gethostbyname
| From: | tonyhana at sixzeros dot com | Date: | Thu, 04 Jul 2002 11:43:43 +0000 |
| Subject: | note 22927 added to function.gethostbyname | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-32581@lists.php.net to get a copy of this message | ||
<?php
//script to time DNS propagation
//(Above script modified slightly to show micro time)
//seems pretty damn quick to me.. I'm getting .0055 sec worstcase badhost times.
//A known good dns name (my own)
$nametotest = "fuzzygroup.com";
//Call address test function
$time_start = getmicrotime();
testipaddress($nametotest);
$time_end = getmicrotime();
$time = $time_end - $time_start;
echo "Good Host Search took $time seconds<br><br>";
//A known bad name (trust me)
$nametotest = "providence.mascot.com";
$time_start = getmicrotime();
testipaddress($nametotest);
$time_end = getmicrotime();
$time = $time_end - $time_start;
echo "Bad Host Search took $time seconds<br>";
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
//ip address checking function
//for real use should have a return value but example code
function testipaddress ($nametotest) {
$ipaddress = $nametotest;
$ipaddress = gethostbyname($nametotest);
if ($ipaddress == $nametotest) {
echo "No ip address for host<br>";
}
else {
echo "good hostname, $nametotest ipaddress = $ipaddress<br>";
}
}
//Recommended fix for sql applications:
// store url to temporary table
// run second process periodically to
// check urls and update main table
?>
--
http://www.php.net/manual/en/function.gethostbyname.php
http://master.php.net/manage/user-notes.php?action=edit+22927
http://master.php.net/manage/user-notes.php?action=delete+22927
http://master.php.net/manage/user-notes.php?action=reject+22927