1$response = null;
2system("ping -c 1 google.com", $response);
3if($response == 0)
4{
5 // this means you are connected
6}
1function is_connected()
2{
3 $connected = @fsockopen("www.example.com", 80);
4 //website, port (try 80 or 443)
5 if ($connected){
6 $is_conn = true; //action when connected
7 fclose($connected);
8 }else{
9 $is_conn = false; //action in connection failure
10 }
11 return $is_conn;
12
13}