A method to check host name network status with PHP

This is a method to check if a host name is accessible i.e it is online, by using PHP. With fsocketopen() a connection will be created, if it fails false will be returned otherwise it will return a pointers.

In this script gets pinged on port 80 the conditional statement will output simple statements based on the fsocketopen() response. Errors are suppressed with the @.

if (@fsockopen("", 80) === false) {
   echo "Down";
} else {
   echo "Up";

If a connection was not rejected it will output Up otherwise the output will be Down.