For my cURL resource in PHP CLI, I have set a file stream as to where the downloaded content should be saved to, with the help of curl_setopt(CURLOPT_FILE, $handle), where $handle is valid file resource where I can write to.
Now I would like to reuse the same curl resource, clear the file handle so I can execute the curl requests and capture the output with output buffering.
I’ve read that you’re supposed to do curl_setopt(CURLOPT_FILE, STDOUT), but the problem with that is that it bypasses the output buffer, and any request I execute is output to my cli and is not capturable by output buffering.
I also tried closing the file handle, but that just made the responses disappear into void.
So does anyone know the solution?
You could try setting CURLOPT_RETURNTRANSFER to true, that should override writing into a file
To get headers