Jump to content

Why HEADER? Why not META Refresh...


phpSensei

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.