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 8063219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:57:11+00:00 2026-06-05T10:57:11+00:00

I am wondering if it is possible to save the entire http response on

  • 0

I am wondering if it is possible to save the entire http response on the server side at the end of some php script just before sending reponse? Even better if i can save response in hex format? Or can i see it in apache log maybe?

many thanks

Edit:

      function shutDownFunction() {


        $error = error_get_last();

        if ( !empty($error) ) {

            header('HTTP/1.0  500' .$error );
        } else { 
           header('HTTP/1.0 200');
           return '<html> <body> ... </body></html>';
        }



    }

register_shutdown_function('shutdownFunction');

try { 

 $data = file_get_contents("php://input");

  //do some work here 

    } catch (Exception $e) {

        header('HTTP/1.0 503'); 

        die;
    }

And I want to save entire response inluding headers, i don-t know , for example :

GET /tutorials/other/top-20-mysql-best-practices/ HTTP/1.1
Host: net.tutsplus.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: PHPSESSID=r2t5uvjq435r4q7ib3vtdjq120
Pragma: no-cache
Cache-Control: no-cache
  • 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-05T10:57:12+00:00Added an answer on June 5, 2026 at 10:57 am
    <?php
    function callback($buffer)
    {
      // Save the output (to append or create file)
      $fh = fopen("out.txt", "a");
      fwrite($fh, $buffer);
      fclose($fh);
    
      // Return the output
      return $buffer;
    }
    
    // Any thing that is indended to be sent to the client is stored in a buffer and callback is called
    ob_start("callback");
    
    // Write out to buffer here
    echo "TEST";
    echo " SOME MORE DATA";
    echo "\r\nNEW LINE";
    echo "<b>SOME HTML</b>";
    
    // Send to client
    ob_end_flush();
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if it is possible to save some data with PHP getting
Just toying with the SDK and I was wondering if possible a UITouch event
I was wondering if it would be possible to save different versions of a
I was wondering if it is possible to save C# code fragments to a
I was wondering if it's possible to save the contents of a html form
Wondering if it is possible for my claims aware application (ASP.NET) to save a
I'm wondering if it's possible to generate a cookie and save it in a
I was wondering if it's possible to reserve some of an excisting value, while
I am wondering if its possible to get my android application to save a
I'm wondering if its possible to programmatically save admin user details? email, password, first

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.