Answers for "php check internet connection"

PHP
1

php check internet connection

$response = null;
system("ping -c 1 google.com", $response);
if($response == 0)
{
    // this means you are connected
}
Posted by: Guest on April-08-2020
0

php check internet connection

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;

}
Posted by: Guest on January-22-2021

Code answers related to "php check internet connection"

Browse Popular Code Answers by Language