title: PHP cURL GET request is not returning JSON object
body: <p>I'm attempting to use PHP cURL to write a GET request that returns information in JSON format so I can decode it and store the header values accordingly in a Response class.  My request goes through successfully with a 200 Status code, but the actual response is coming back as a string rather than an object that I can work with.   I am using the generated code from Postman for cURL.</p>
  <p>Here my PHP code for the request:</p>
  <pre><code>
          $curl = curl_init();
  
          curl_setopt_array($curl, array(
            CURLOPT_URL =&gt; &quot;http://example.com&quot;,
            CURLOPT_RETURNTRANSFER =&gt; true,
            CURLOPT_ENCODING =&gt; &quot;&quot;,
            CURLOPT_MAXREDIRS =&gt; 10,
            CURLOPT_TIMEOUT =&gt; 0,
            CURLOPT_FOLLOWLOCATION =&gt; true,
            CURLOPT_HTTP_VERSION =&gt; CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST =&gt; &quot;GET&quot;,
            CURLOPT_HEADER =&gt; 1,
            CURLOPT_HTTPHEADER =&gt; array('Content-Type: application/json',
            'Accept: application/json')
          ));
          
         $result = curl_exec($curl);
  
         curl_close($curl);
  
         var_dump($result);
  </code></pre>
  <p>And here is the result I get from the var_dump($result):</p>
  <pre><code>string(1619) &quot;HTTP/1.1 200 OK
  Content-Encoding: gzip
  Age: 455672
  Cache-Control: max-age=604800
  Content-Type: text/html; charset=UTF-8
  Date: Tue, 23 Jun 2020 21:42:08 GMT
  Etag: &quot;3147526947+ident+gzip&quot;
  Expires: Tue, 30 Jun 2020 21:42:08 GMT
  Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
  Server: ECS (sjc/4E73)
  Vary: Accept-Encoding
  X-Cache: HIT
  Content-Length: 648
  
  &lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Example Domain&lt;/title&gt;
  
      &lt;meta charset=&quot;utf-8&quot; /&gt;
      &lt;meta http-equiv=&quot;Content-type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot; /&gt;
      &lt;style type=&quot;text/css&quot;&gt;
      body {
          background-color: #f0f0f2;
          margin: 0;
          padding: 0;
          font-family: -apple-system, system-ui, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif;
  
      }
      div {
          width: 600px;
          margin: 5em auto;
          padding: 2em;
          background-color: #fdfdff;
          border-radius: 0.5em;
          box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);
      }
      a:link, a:visited {
          color: #38488f;
          text-decoration: none;
      }
      @media (max-width: 700px) {
          div {
              margin: 0 auto;
              width: auto;
          }
      }
      &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;div&gt;
      &lt;h1&gt;Example Domain&lt;/h1&gt;
      &lt;p&gt;This domain is for use in illustrative examples in documents. You may use this
      domain in literature without prior coordination or asking for permission.&lt;/p&gt;
      &lt;p&gt;&lt;a href=&quot;https://www.iana.org/domains/example&quot;&gt;More information...&lt;/a&gt;&lt;/p&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  &quot;
  </code></pre>