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
Release: 2016-07-13 09:48:06
Original
936 people have browsed it

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; 
}
Copy after login

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>"; 
}
Copy after login

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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template