Use local css file if link to online css file is dead

前端 未结 3 471
一个人的身影
一个人的身影 2021-01-23 09:32

The problem:


I am using w3.css(if you enter now w3schools.com site is down for maintenance) for styling my website.The problem

3条回答
  •  梦谈多话
    2021-01-23 09:44

    Its possible with PHP. I haven't tested it but it should work.

    Put this inside your tag.

    ';
    } else {
        echo '';
    }
    
    //returns true, if domain is availible, false if not
       function isDomainAvailible($domain)
       {
               //check, if a valid url is provided
               if(!filter_var($domain, FILTER_VALIDATE_URL))
               {
                       return false;
               }
    
               //initialize curl
               $curlInit = curl_init($domain);
               curl_setopt($curlInit,CURLOPT_CONNECTTIMEOUT,10);
               curl_setopt($curlInit,CURLOPT_HEADER,true);
               curl_setopt($curlInit,CURLOPT_NOBODY,true);
               curl_setopt($curlInit,CURLOPT_RETURNTRANSFER,true);
    
               //get answer
               $response = curl_exec($curlInit);
    
               curl_close($curlInit);
    
               if ($response) return true;
    
               return false;
       }
    
    ?>
    

    Reference: https://css-tricks.com/snippets/php/check-if-website-is-available/

提交回复
热议问题