Do PHP cURL options CURLOPT_HEADER and CURLOPT_RETURNTRANSFER conflict
<p>I am using cURL with php to authenticate to an API.
Like this:</p>

<pre><code>$ch = curl_init();
$headers    = [];
$headers[]  = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $this-&gt;url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode( $this-&gt;body ));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$this-&gt;response = json_decode( curl_exec($ch) );
curl_close ($ch);
</code></pre>

<p>The body of the request response contains status code and if request has been successfull the user object. This is an anonymous request and it returns the token in the response headers.</p>

<p>My problem:
The script's above response is null.</p>

<p>If I comment out the CURLOPT_RETURNTRANSFER option, then I get what I need, but it gets echoed out and the response is 1.</p>

<p>If I comment out the CURLOPT_HEADER option, then I get only the body of the response.</p>

<p>I've tried switching between http and https.</p>

<p>I am using PHP-5.5.27.</p>