title: CURL returns response code 200 and 0 for a same page at different time
body: <p>I am facing one unusual behavior of curl. For a given page, I some times get HTTP response code as 200 and sometimes I get 0 as HTTP response code. I am not able to understand whether this page is valid or not. If you try the given code, please try it for at least 5-10 times so that you can see the difference. </p>
  
  <pre><code>function print_info()
  {
      $url = 'bart.no';
      $arr = array(
      'bart.no',
      'bolandirekt.nu',
      'ekompassen.com',
      'ekompassen.nu',
      );
  
      foreach ($arr as $url)
      {
          echo "&lt;br/&gt;URL: " . $url;
          $temp = str_replace(array("www.", "http://", "https://"), "", strtolower($url));
  
          // From this array it will be decided which is to prepend
          $pre_array = array("", "www.", "https://", "http://", "https://www.", "http://www.");
          $status_code = array();
  
          // For each Value Status will be stored
          foreach ($pre_array as $pre)
          {
  
              $options = array(
                  CURLOPT_RETURNTRANSFER =&gt; TRUE, // return web page
                  CURLOPT_HEADER =&gt; TRUE, // don't return headers
                  CURLOPT_FOLLOWLOCATION =&gt; FALSE, // follow redirects
                  CURLOPT_ENCODING =&gt; "", // handle all encodings
                  CURLOPT_USERAGENT =&gt; "spider", // who am i
                  CURLOPT_AUTOREFERER =&gt; FALSE, // set referer on redirect
                  CURLOPT_SSL_VERIFYHOST =&gt; FALSE, //ssl verify host
                  CURLOPT_SSL_VERIFYPEER =&gt; FALSE, //ssl verify peer
                  CURLOPT_NOBODY =&gt; FALSE,
                  CURLOPT_CONNECTTIMEOUT =&gt; 20, // timeout on connect
                  CURLOPT_TIMEOUT =&gt; 20, // timeout on response
              );
  
              // Initializing Curl
              $ch = curl_init($pre . $temp);
              // Set Curl Options
              curl_setopt_array($ch, $options);
              // Execute Curl
              $content = curl_exec($ch);
  
              $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
              echo "&lt;pre/&gt;";
              if ($code == 200)
              {
                  print_r(curl_getinfo($ch));
                  break;
              }           
                              curl_close($ch);
          }
      }
  }
  </code></pre>
  
  <p>So my final doubt is : Why I am getting response code 200 for the pages which are not existing Or not opening in browser ? Also, why sometimes I get response code 0 and sometimes response code 200 for the same page even if I keep time interval between requests ?</p>