Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8783451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:50:00+00:00 2026-06-13T20:50:00+00:00

For my cURL resource in PHP CLI, I have set a file stream as

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:50:02+00:00Added an answer on June 13, 2026 at 8:50 pm

    You could try setting CURLOPT_RETURNTRANSFER to true, that should override writing into a file

    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($curl_handle);
    

    To get headers

    curl_setopt($curl_handle , CURLOPT_HEADER , true);
    $result = curl_exec($curl_handle);
    list($header , $data) = explode("\r\n\r\n" , $result , 2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

curl_setopt($ch, CURLOPT_FILE, $fp) which is used for output to a file. Is any way
<?php // create a new CURL resource $file_path = '/mail'; define(COOKIE_FILE, c:\cookie.txt); $ch =
I have a strange problem with PHP and cURL using windows. If have a
my curl function cannot follow the redirection of Facebook external link redirector, l.php and
Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a simple cURL script that works just fine. But I'm curious about
I have a question regarding HTTP Digest Auth using curl, and sending post data
I'm making a PHP class that handles some traffic with the use of CURL
I'm completely newbie in PHP. I have tried example code from this site .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.