Re: PHP: how to ping a server ? ...addendum
| From: | Steve Edberg | Date: | Tue, 19 Dec 2000 23:50:51 +0000 |
| Subject: | Re: PHP: how to ping a server ? ...addendum | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31100@lists.php.net to get a copy of this message | ||
At 01:23 PM 12/19/00 , Steve Edberg wrote:
Hi Paul - Are you actually trying to check an HTTP return status code? You'll have to do something a little more complex - open a connection to the server, send a HTTP request (eg; HEAD), and parse the response.<SNIP>
fputs ($fp, "HEAD / HTTP/1.0\r\n\r\n");
if (!feof($fp) && $Line = fgets($fp,128)) {
I can't remember PHP operator precedence at the moment (it's in the manual section on operators, I believe), but to be on the safe (and IMHO slightly more readable) side this line should probably be:
if ( !feof($fp) && ($Line = fgets($fp,128)) ) {
$Bits = split('[[:space:]]+', $Line);
$Status = $Bits[1];
}
fclose ($fp);
}
return array($Status, $Errno);
}
- steve+------------------------------------------------------------------------+
| Steve Edberg University of California, Davis | | sbedberg@ucdavis.edu (530)754-9127 | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ |+---------------------- Gort, Klaatu barada nikto! ----------------------+