Home > Backend Development > PHP Tutorial > PHP method to determine whether connected to the network_PHP tutorial

PHP method to determine whether connected to the network_PHP tutorial

WBOY
Release: 2016-07-13 09:47:33
Original
967 people have browsed it

How PHP determines whether it is connected to the network

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

 ?

1

2

3

4

5

6

7

8

9

function varify_url($url){

$check = @fopen($url,"r");

if($check){

$status = true;

}else{

$status = false;

}

return $status;

}

1

2

3

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
";

}

4

5

6

8 9
function varify_url($url){ $check = @fopen($url,"r"); if($check){ $status = true;
}else{
$status = false; } return $status; }
Then just call it directly where needed  ?
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
"; }
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/1025333.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1025333.htmlTechArticleHow PHP determines whether it is connected to the network. This example 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...
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