📜  php 检查互联网连接 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:14.740000             🧑  作者: Mango

代码示例2
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;

}