PHP 7 Script to Check Internet Connection in Browser Full Project For Beginners

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments

 

Welcome folks today in this blog post we will be checking internet connection in browser using php 7. All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to make an index.php file and copy paste the following code

 

 

index.php

 

 

 

<?php
//Checking internet connection status with predefined function
switch (connection_status())
{
case CONNECTION_NORMAL:
  $msg = 'You are connected to internet.';
  break;
case CONNECTION_ABORTED:
  $msg = 'No Internet connection';
  break;
case CONNECTION_TIMEOUT:
  $msg = 'Connection time-out';
  break;
case (CONNECTION_ABORTED & CONNECTION_TIMEOUT):
  $msg = 'No Internet and Connection time-out';
  break;
default:
  $msg = 'Undefined state';
  break;
}
//display connection status
echo $msg;
?>

Leave a Reply