Checking if a Host Is Alive

Use PEAR's Net_Ping package:
require 'Net/Ping.php';

$ping = new Net_Ping;
if ($ping->checkhost('www.oreilly.com')) {
    print 'Reachable';
} else {
    print 'Unreachable';
}

$data = $ping->ping('www.oreilly.com');
 
The ping program tries to send a message from your machine to another.
 If everything goes well, you get a series of statistics chronicling the transaction. An error means that ping can't reach the host for some reason.
On error, Net_Ping::checkhost( ) returns false
and Net_Ping::ping( ) returns the constant PING_HOST_NOT_FOUND. If there's a problem running the ping program (because Net_Ping is really just a wrapper for the program), PING_FAILED is returned.