title: PHP, Curl - Check for empty result
body: <p>Most of the time the URL will return some information, however when no information is returned, I want to return a string 'Empty Result', so not to be passing an empty string to SimpleXmlElement function as this seems to produce an error.</p>
  
  <p>How do I check for a empty/null response from Curl?</p>
  
  <pre><code>    // Get cURL resource
      $curl = curl_init();
  
      // Set some options - we are passing in a useragent too here
      curl_setopt_array($curl, array(
          CURLOPT_RETURNTRANSFER =&gt; 1,
          CURLOPT_URL =&gt; $searchString,
          CURLOPT_USERAGENT =&gt; 'Codular Sample cURL Request',
          CURLOPT_FOLLOWLOCATION, true
      ));
      // Send the request &amp; save response to $resp
      $result = curl_exec($curl);
  
      // Close request to clear up some resources
      curl_close($curl);
  
      if($result === null)
      {
          return 'Empty Result';
      }
  
      $doc = new SimpleXmlElement($result, LIBXML_NOCDATA);
  </code></pre>