Jump to content

Recommended Posts

that will just spit out the content after running the header(), with the net effect of having a delayed header redirect with no content output between.  or, in short, a user going nuts seeing a blank page for 3 seconds.

though you can make header() pause too. aka.

 

echo("chnages saved.  you will be redirected...");

sleep(3);  // pause for 3 seconds

header("location: url");

 

Nope thats will fail.. nothing can be sent to the screen before a header

 

This is not strictly true, there is an option in php.ini (named output_buffering I believe) that allows you to do such things. So it really is dependent on the server enviroment you are in.

This is not strictly true, there is an option in php.ini (named output_buffering I believe) that allows you to do such things. So it really is dependent on the server enviroment you are in.

output_buffering is the size of the buffer for ob_start.. so no it will not work!

 

 

 

i dont test my coding lol.  i said from what i knew the three functions do :)

 

you might need to read that :P

i quoted a statement not code the statement also included "it will", thus i corrected you.

 

:P

 

PS. you should see some of the code i posted for people.. kinda surprised they tried it! lol

just so that everyone is clear on what output buffering does:  it does NOT send content before header calls.  what it does is captures any browser output made during the script's execution, runs the header() calls when found, and finally FLUSHES that output once the script is done running (or an ob flush routine is called).

 

therefore headers will STILL PRECEDE content output and always will, it will just not send out an error because PHP is "biding its time" so to speak, before it actually outputs to the browser.

I've done a lot of programming and never used output buffering. What's the point in it? It seems to me that it just lets you get away with bad programming practices which is not good... makes the logic hard to follow. Please someone chime in and educate me on a more practical use if there is one.

When doing little development for your own stuff or friends maybe this is fine.... when doing it for a client it's not really acceptable to accept that it works, there's more to it than that. You may not be the person who does maintenance in the future so things should be done correctly.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.