PHP Ping

<?php

function ping($host, $port, $timeout) {
$tB = microtime(true);
$fP = fSockOpen($host, $port, $errno, $errstr, $timeout);
if (!$fP) { return "down"; }
$tA = microtime(true);
return round((($tA – $tB) * 1000), 0)." ms";
}

echo ping(‘www.google.com’, 80, 10);

?>

Published by

@XiaoKyun

双鱼男,过分热心的好人。