Php code used to check whether the URL address and http address format are valid 
 
  
   
    
     
      
     -  /**
  
     - Desc: Check whether the network address format is valid
  
     - Link: bbs.it-home.org
  
     - Date:
  
     - */
  
     - Function checkUrl ($ weburl)
  
     - {
  
     - Return! Ereg ("^ http (s) *: // [_ a-zA-Z0-9-] + (. [_ a-zA-Z0-9-] +) * $", $ weburl );
  
     - }?>
  
      
      2. determine whether the http address is valid  
     
      
      
      /**   
     - Desc: checks whether the http address is valid
  
     - Link: bbs.it-home.org
  
     - Date:
  
     - */
  
     - Function url_exists ($ url)
  
     - {
  
     - $ Ch = curl_init ();
  
     - Curl_setopt ($ ch, CURLOPT_URL, $ url );
  
     - Curl_setopt ($ ch, CURLOPT_NOBODY, 1); // do not download
  
     - Curl_setopt ($ ch, CURLOPT_FAILONERROR, 1 );
  
     - Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
  
     - Return (curl_exec ($ ch )! = False )? True: false;
  
     - }
  
     // Method 2   
     - Function img_exists ($ url)
  
     - {
  
     - Return file_get_contents ($ url, 0, null, 0, 1 )? True: false;
  
     - }
  
     // Method 3:   
     - Function url_exists ($ url)
  
     - {
  
     - $ Head = @ get_headers ($ url );
  
     - Return is_array ($ head )? True: false;
  
     - }?>
  
      
      Call example:  
     
      
     -  $ Url = 'http: // bbs.it-home.org ';
  
     - Echo url_exists ($ url );
  
     - ?>
  
       |