Last active
December 19, 2017 13:36
-
-
Save vmosoti/7a71011622eecbc5831c1ecb4cebdff1 to your computer and use it in GitHub Desktop.
Check if Server is Connected to Internet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function is_connected() | |
{ | |
$connected = @fsockopen("www.example.com", 80); | |
//website, port (try 80 or 443) | |
if ($connected){ | |
$is_conn = true; //action when connected | |
fclose($connected); | |
}else{ | |
$is_conn = false; //action in connection failure | |
} | |
return $is_conn; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment