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

  • Home
  • SEARCH
  • 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 6534051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:12:15+00:00 2026-05-25T10:12:15+00:00

Does PHP send over code as it processes the file, or does it compose

  • 0

Does PHP send over code as it processes the file, or does it compose the whole HTML response and then send it over? For example would it make any difference to move expensive PHP functions into the file footer on the server?

Also, would it make any difference if you were using Transfer-Encoding: chunked?

  • 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-05-25T10:12:15+00:00Added an answer on May 25, 2026 at 10:12 am

    Ultimately, it depends. Most PHP hosting mechanisms I have used will stream the response in chunks, as it is received from the script, omitting the Content-Length header entirely (since this is not known in advance). You can flush the response using flush() periodically to force the server to transmit what it has buffered so far to the client.

    So, if you are going to be doing things that take a lot of time and want to allow the page to render in advance, the proper way to do this would be to output as much of the page as possible, call flush(), and then do your expensive tasks. Just be sure not to take longer than the declared maximum PHP script duration.


    Okay, so that explanation is admittedly a bit oversimplified:

    The Content-Length header may actually be sent under some circumstances. For example, if the script’s response is less than PHP’s buffer for sent data, and/or if the script takes under a certain amount of time to execute, then the server will know exactly how long the content is and can add the length header.

    Further, flush() may not actually do anything. This depends on your server configuration and other factors. Note specifically these warnings in the documentation regarding server-side behavior:

    flush() may not be able to override the buffering scheme of your web server and it has no effect on any client-side buffering in the browser. It also doesn’t affect PHP’s userspace output buffering mechanism. This means you will have to call both ob_flush() and flush() to flush the ob output buffers if you are using those.

    Several servers, especially on Win32, will still buffer the output from your script until it terminates before transmitting the results to the browser.

    Server modules for Apache like mod_gzip may do buffering of their own that will cause flush() to not result in data being sent immediately to the client.

    In other words: test, test, test. Make sure that the web server isn’t interfering with the behavior you’re trying to achieve. Reconfigure the web server if necessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone have any experience using PHP to send an sms via skype I
With Php when does an included file get included? Is it during a preprocessing
Can anyone explain what the following PHP Code does function query($query_string) { if ($query_string
I can't seem to get my php script to send email. <?php echo Does
Ok, I'm trying to play an HTML audio code on iPad but does not
Thanks to this forum, I learnt PHP header function does not actually send header
Does anybody know how to use PHP to send product data to Amazon.com? I
Does PHP have a method of having auto-generated class variables? I think I've seen
Does PHP expose Apache's Mime-Type to extension mapping in any way shape or form.
does PHP support something like ampersand in bash (forking)? Let's say I wanted to

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.