Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Error checking and handling is the programmer's friend. Check the return values of the initializing and executing cURL functions. <a href="http://php.net/manual/en/function.curl-error.php" rel="noreferrer"><code>curl_error()</code></a> and <a href="http://php.net/manual/en/function.curl-errno.php" rel="noreferrer"><code>curl_errno()</code></a> will contain further information in case of failure:</p> <pre><code>try { $ch = curl_init(); // Check if initialization had gone wrong* if ($ch === false) { throw new Exception('failed to initialize'); } curl_setopt($ch, CURLOPT_URL, 'http://example.com/'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt(/* ... */); $content = curl_exec($ch); // Check the return value of curl_exec(), too if ($content === false) { throw new Exception(curl_error($ch), curl_errno($ch)); } /* Process $content here */ // Close curl handle curl_close($ch); } catch(Exception $e) { trigger_error(sprintf( 'Curl failed with error #%d: %s', $e-&gt;getCode(), $e-&gt;getMessage()), E_USER_ERROR); } </code></pre> <hr> <p><sup>*</sup> The <code>curl_init()</code> <a href="http://php.net/manual/en/function.curl-init.php" rel="noreferrer">manual</a> states:</p> <blockquote> <p>Returns a cURL handle on success, <strong>FALSE</strong> on errors.</p> </blockquote> <p>I've observed the function to return <code>FALSE</code> when you're using its <code>$url</code> parameter and the domain could not be resolved. If the parameter is unused, the function <em>might</em> never return <code>FALSE</code>. Always check it anyways, though, since the manual doesn't clearly state what "errors" actually are.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload