This article mainly introduces PHP through the AJAX call to connect Baidu effect to detect whether the Web site is connected to the function of interested friends under the reference, I hope to help you.
In this paper, the method of Php+ajax real-time automatic detection is described, and the implementation method is as follows:
HTML Part code:
<! DOCTYPE Html>
PHP Section 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 = "<font color=\" red\ "> Network connection Failed </font>"; } else{ $shownetlink = "<font color=\" #06C \ "> Network connection Normal </font>"; } Echo $shownetlink; }
Summary : The above is the entire content of this article, I hope to be able to help you learn.
Related recommendations:
The definition and implementation of PHP for event mechanism
PHP-based method for skin changing with cookies
Three common uses of PHP analog post requests