I am trying to load a page using Curl. The page loads correctly, as expected. But the problem is that Curl prints all the content, rather than saving it to a variable as I want.
The code is as follows:
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
$result = curl_exec($ch);
curl_close($ch);
With the exception of initializations, this is all the contents of the php file. It may not be much simpler than this, but it prints the contents and does not save it in the $ result variable.
I tried:
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
I also tried a bunch of other addresses, the same result. Did I miss something?
Perhaps I need to set another Curl parameter or do I need to change some parameters of my test server?
source
share