This article mainly introduces the relevant information of PHP Ajax to detect whether the network is normal. The example code is attached here. Friends in need can refer to it.
The specific implementation method is as follows:
html part code:
php part code:
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; }
The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
jsDetectiontest网NetworkStatus Code Arrangement
##Linux How toCheckTestServerNetworkNetworkStatus
Detectiontest网网 Whether to specifically connect the function code_javascript skills
The above is the detailed content of Detailed explanation of the case of PHP+Ajax detecting whether the network is normal. For more information, please follow other related articles on the PHP Chinese website!