PHP Code Detect Internet Connection - Php

How to detect internet connection using PHP code??

Snippet Code


  
Rate this page :
  [ 0 votes]

Use chk_connection() function to detect the internet connection in PHP. If it returns the value 1, internet is connected, else not connected.

<?php function chk_connection($check) { return (bool) @fsockopen($check, 80, $iErrno, $sErrStr, 5); } $result = chk_connection('www.hscripts.com'); if($result=='1') { echo "Connected"; } else{ echo "Not Connected"; } ?>

Tags


Ask Questions

Ask Question