Home > php教程 > php手册 > body text

PHP+Ajax实时自动检测是否联网的方法

WBOY
Release: 2016-06-06 20:02:39
Original
772 people have browsed it

这篇文章主要介绍了PHP+Ajax实时自动检测是否联网的方法,通过Ajax调用连接百度效果实现检测网站是否联网的功能,需要的朋友可以参考下

本文实例讲述了PHP+Ajax实时自动检测是否联网的方法。分享给大家供大家参考。具体实现方法如下:

html部分代码:

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

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

当前网络状态:

php部分代码:

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

希望本文所述对大家的php程序设计有所帮助。

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template