Home > Backend Development > PHP Tutorial > A small example of PHP determining whether it is connected to the Internet

A small example of PHP determining whether it is connected to the Internet

WBOY
Release: 2016-07-25 08:56:04
Original
1064 people have browsed it
  1. //Check whether the network is connected
  2. function varify_url($url){
  3. $check = @fopen($url,"r");
  4. if($check){
  5. $status = true;
  6. }else{
  7. $status = false;
  8. }
  9. return $status;
  10. } //by bbs.it-home.org
Copy code

Call example:

  1. $url = "http://bbs.it-home.org";
  2. if(varify_url($url)){
  3. echo "
    Congratulation ! Your URL < ;a href=$url>$url : is valid
    ";
  4. }else{
  5. echo "
    Error ! The URL you provided: $url is invalid
    ";
  6. }
Copy code


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