Home > Backend Development > PHP Tutorial > How to automatically detect whether the Internet is connected to the Internet using PHP Ajax in real time_PHP Tutorial

How to automatically detect whether the Internet is connected to the Internet using PHP Ajax in real time_PHP Tutorial

WBOY
Release: 2016-07-13 09:47:43
Original
827 people have browsed it

How to automatically detect whether PHP Ajax is connected to the Internet in real time

This example describes the method of PHP Ajax to automatically detect whether it is connected to the Internet in real time. Share it with everyone for your reference. The specific implementation method is as follows:

HTML part code:

 ?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

PHP Ajax实时自动检测是否联网

PHP Ajax实时自动检测是否联网

当前网络状态:

1

2

3

1

2

3

4

5

6

7

8

9

10

11

public function getNetLink(){

header("cache-control:no-cache,must-revalidate");

header("Content-Type:text/html;charset=utf-8");

$file=fopen("http://www.baidu.com/", "r");

if (!$file){

$shownetlink = "网络连接失败";

}else{

$shownetlink = "网络连接正常";

}

echo $shownetlink;

}

4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
<🎜>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> PHP Ajax automatically detects whether the Internet is connected in real time

PHP Ajax automatically detects whether the Internet is connected in real time

Current network status:

PHP part code:  ?
1 2 3 4 5 6 7 8 9 10 11 public function getNetLink(){ header("cache-control:no-cache,must-revalidate"); header("Content-Type:text/html;charset=utf-8"); $file=fopen("http://www.baidu.com/", "r"); if (!$file){ $shownetlink = "Network connection failed"; }else{ $shownetlink = "Network connection is normal"; } echo $shownetlink; }

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1025328.htmlTechArticleHow PHP Ajax automatically detects whether it is connected to the Internet in real time. This example describes how PHP Ajax can automatically detect whether it is connected to the Internet in real time. 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