Home >Backend Development >PHP Tutorial >PHP method to determine whether to connect to the network, PHP to determine whether to connect to the network_PHP tutorial

PHP method to determine whether to connect to the network, PHP to determine whether to connect to the network_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:48:06969browse

How PHP determines whether it is connected to the network, PHP determines whether it is connected to the network

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1024907.htmlTechArticleHow PHP determines whether it is connected to the network, php determines whether it is connected to the network. This article describes how PHP determines whether it is connected to the network. method. Share it with everyone for your reference. The specific implementation method is as follows...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn