title: curl_close(): is not a valid cURL handle resource ... but WHY?
body: <p>I'm making a PHP class that handles some traffic with the use of CURL and everything works quite well (except for cookies but hey that's another thing). One thing that doesn't work that great is the curl_close() function though and I have no idea why...</p>
  
  <pre><code>$curlSession = &amp;$tamperCurl-&gt;getCURLSession();
  
  var_dump($curlSession);
  curl_close($curlSession);
  die();
  </code></pre>
  
  <p>I previously called curl_exec() and everything worked perfectly. The output this is giving me is:
      resource(6) of type (curl)
      <br />
      <b>Warning</b>:  curl_close(): 6 is not a valid cURL handle resource in
      <b>filename.php</b> on line <b>58</b><br /></p>
  
  <p>Does anybody have any idea why this is happening? (the var_dump is saying that it's obviously a curl session).</p>
  
  <p>ADDITION:</p>
  
  <p>Because of copyright problems I cannot post the whole TamperData class atm (it will be GPL later).</p>
  
  <p>I have simplified it to this:</p>
  
  <pre><code>$tamperCurl = new TamperCurl('test.xml');
  echo var_dump($tamperCurl-&gt;getCURLSession());
  curl_close($tamperCurl-&gt;getCURLSession());
  die();
  </code></pre>
  
  <p>The constructor of TamperCurl is like this:</p>
  
  <pre><code>public function __construct($xmlFilePath, $options=null)    
  {
      if($options != null) $this-&gt;setOptions($options);
  
      $this-&gt;headerCounter = 0;
      $this-&gt;setXMLHeader($xmlFilePath);
      $this-&gt;init();
  }
  
  public function init($reuseConnection=false,$resetSettings=null)
  {
      $this-&gt;curlSession = curl_init();
  }
  </code></pre>
  
  <p>Again the same output:
      resource(8) of type (curl)
      PHP Warning:  curl_close(): 8 is not a valid cURL handle resource in TamperCurl.php on line 58</p>