This article mainly introduces the method of PHP to determine whether it is connected to the Internet. It uses PHP to determine whether it can open the Baidu page to determine whether it is connected to the Internet. Friends who need it can refer to it.
The specific implementation method is as follows:
First write a function
function varify_url($url){ $check = @fopen($url,"r"); if($check){ $status = true; }else{ $status = false; } return $status; }
Then call it directly where needed
$url = "http://www.baidu.com"; if(varify_url($url)){ echo "<p>Congratulation ! Your URL <a href=$url>$url</a> : is <b>valid </b></p>"; }else{ echo "<p>Error ! Your URL : <a href=$url>$url</a> is <b>invalid </b></p>"; }
The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
PHP method to determine whether to connect to the network_PHP
The above is the detailed content of Detailed explanation of how PHP determines whether it is connected to the Internet. For more information, please follow other related articles on the PHP Chinese website!