Vercas Vercas - 2 years ago 101
PHP Question

Determine whether an IP is online or not in PHP?

I have a few IPs (other servers hosting large binary files) and their static IP.

When a user clicks on a link, I want to ping each server until it finds one that is online and redirect the browser to the appropriate URI. If none of the servers are online, it should display an error.

Answer Source

look at this.... Ping site and return result in PHP

function availableUrl($host, $port=80, $timeout=10) { 
  $fp = fSockOpen($host, $port, $errno, $errstr, $timeout); 
  return $fp!=false;

//Return "true" if the url is available, false if not.
echo availableUrl("");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download