Development

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 192.168.0.1 gets pinged on port 80 the conditional statement will output simple statements based on the fsocketopen() response. Errors are suppressed with the @.

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

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

Share

Recent Posts

Kennington reservoir drained drone images

A drained and empty Kennington reservoir images from a drone in early July 2024. The…

1 year ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

1 year ago

FTP getting array of file details such as size using PHP

Using FTP and PHP to get an array of file details such as size and…

2 years ago

Creating Laravel form requests

Creating and using Laravel form requests to create cleaner code, separation and reusability for your…

2 years ago

Improving the default Laravel login and register views

Improving the default Laravel login and register views in such a simple manner but making…

2 years ago

Laravel validation for checking if value exists in the database

Laravel validation for checking if a field value exists in the database. The validation rule…

2 years ago