This article describes the example of 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
?
2 3
4 56 |
function varify_url($url){
$check = @fopen($url,"r");
if($check){
$status = true;
}else{
$status = false;
}
return $status;
}
|
1 2 3 4 5 6 |
$url = "http://www.baidu.com";
if(varify_url($url)){
echo " Congratulation ! Your URL $url : is valid ";
}else{
echo "Error ! Your URL : $url is invalid ";
}
|