title: Having trouble retrieving JSON with curl to parse in php
body: <p>I'm attempting too fetch and parse JSON in PHP via curl. I am unable to parse the response, and see it dumping to my screen instead. Here is sample code.</p>
  
  <pre><code>&lt;?php
  
  $url = 'XXXXXXXXXXXXXXXXXXXXX';
  
  $cURL = curl_init();
  
  curl_setopt($cURL, CURLOPT_URL, $url);
  curl_setopt($cURL, CURLOPT_HTTPGET, true);
  
  curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
  'X-Mashape-Key: XXXXXXXXXXXXXXXXXXXXXXXXX',
  'Accept: application/json'
  ));
  
  $result = curl_exec($cURL); ## this seems to be the line printing the response?
  
  curl_close($cURL);
  
  echo "&lt;br /&gt;--------------------------------------------------------&lt;br /&gt;";
  
  var_dump($cURL);
  
  echo "&lt;br /&gt;--------------------------------------------------------&lt;br /&gt;";
  
  var_dump($result);
  
  echo "&lt;br /&gt;--------------------------------------------------------&lt;br /&gt;";
  
  $json = json_decode($result);
  
  echo "&lt;br /&gt;--------------------------------------------------------&lt;br /&gt;";
  
  print_r($json);
  
  echo "&lt;br /&gt;--------------------------------------------------------&lt;br /&gt;";
  
  echo $json-&gt;word;
  echo $json-&gt;definitions[0]-&gt;definition;
  
  echo "&lt;br /&gt;--------------------------------------------------------&lt;br /&gt;";
  
  ?&gt;
  </code></pre>
  
  <p>And the output is:</p>
  
  <pre><code>{"word":"incredible","definitions":[{"definition":"beyond belief or understanding","partOfSpeech":"adjective"}]}
  --------------------------------------------------------
  resource(2) of type (Unknown) 
  --------------------------------------------------------
  bool(true) 
  --------------------------------------------------------
  
  --------------------------------------------------------
  1
  --------------------------------------------------------
  
  --------------------------------------------------------
  </code></pre>
  
  <p>See how my JSON is appearing on screen before my first echo statement? Why is this happening?</p>