- microtime: documentation ( source)
- round: documentation ( source)
- fsockopen: documentation ( source)
<?php
echo '<form enctype="multipart/form-data" action="ping.php" method="post">
<p>Podpis:</p><input class="imie" name="strona" type="text" maxlength="30" SIZE="30"><br>
<br><br><input type="submit" class="button2" value="pinguj">';
function ping($host) {
$tB = microtime(true);
$fP = fSockOpen($host, 80, $errno, $errstr, 10);
if (!$fP) { return "down"; }
$tA = microtime(true);
return round((($tA - $tB) * 1000), 0)." ms";
}
if( isset($_POST['strona']) ){
for($x=1;$x<=10;$x++)
{
echo ping("$_POST[strona]")."<br>";
}
}
?>