The example in this article describes how PHP determines whether it is connected to the network. Share it with everyone for your reference. 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 just call it directly where needed
$url = "http://www.baidu.com"; if(varify_url($url)){ echo "<div>Congratulation ! Your URL <a href=$url>$url</a> : is <b>valid </b></div>"; }else{ echo "<div>Error ! Your URL : <a href=$url>$url</a> is <b>invalid </b></div>"; }
I hope this article will be helpful to everyone’s PHP programming design.