Results 1 to 6 of 6

Thread: loading a (whole) php webpage

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    156

    loading a (whole) php webpage

    Is there any code that would load the whole of a page and then show it, instead of a browser showing what it can whilst it loads?

  2. #2
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: loading a (whole) php webpage

    Output buffering?

    Start your page(s) off with:
    Code:
    <?php
    ob_start();
    ?>
    ...and end them with...
    Code:
    <?php
    ob_end_flush();
    ?>
    I don't think you even really need ob_end_flush() at the end - the output buffer automatically flushes itself when it gets to the end of the page (if you haven't told it to do otherwise).

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: loading a (whole) php webpage

    Unless the script in question takes an abnormally long time to run, output buffering is not the solution to the problem described. The browser is in fact waiting for the script output to be transmitted, not for the server to process the script. There is no way you can control this from the server side.

    There are two primary cases in which output buffering is useful:

    1. The script takes a long time to run by design. Manually flushing the buffer regularly will ensure that the latest output is being shown to the user, rather than being stored in the server-side buffer.

    2. You wish to post-process the output before sending it to the client. Perhaps your script produces some sort of intermediate output (like XML) which you then transform into a client-consumable format such as HTML or XHTML.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    156

    Re: loading a (whole) php webpage

    Ok thanks,
    I'll have a look at using something other than Php

  5. #5
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: loading a (whole) php webpage

    Thanks penagate - just curious, any thoughts how you'd go about doing this? If it has to be done client-side, are CSS and Javascript the only methods available?

    What comes to mind for me is to put an overlay div over the entire page:
    Code:
    <div style="position:absolute;top:0;left:0;width:100%;height:100%; background:#fff;z-index:2;"></div>
    ...and then get rid of it with Javascript when the page is loaded. But this would be horrible for the user if they have Javascript turned off... But if any solution is going to require Javascript anyway...

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: loading a (whole) php webpage

    Flash or JavaScript are the two methods which come to mind. Both inelegant.

    If using JavaScript, you could perhaps use a style rule set in a noscript block to ensure the overlay is hidden when JS is not available.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width