Drezard Posted February 27, 2007 Share Posted February 27, 2007 Hey I'm wondering with these scripts (http://evolt.org/PHP-Login-System-with-Admin-Features) here how does the Header() function supposed to work? It seems like everyone likes to set cookies and send headers in the middle of there script. Now, did this work in PHP4 or do I need some PERL or Add-on so I can send headers and such. I know u have a FAQ all about this. It just makes no sense about how to fix the problem. Its only a diagnostic. Okay, Please explain... Cheers, Daniel Quote Link to comment Share on other sites More sharing options...
btherl Posted February 27, 2007 Share Posted February 27, 2007 You can output headers with Header() as long as you have not yet produced any other output. Same with cookies. If it's not working, you need to find where the output has already been produced. You haven't explained what you are trying to do and what is going wrong. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted February 27, 2007 Share Posted February 27, 2007 You can output headers where ever you like if you use ob_start and ob_end_flush. I used to reserve these for building my cms's as not so many would be in the cms for long periods so I thought it would not matter about server load and runtime etc. I read an article recently that suggest that if you have lots of output statements all over (echo, print_r etc.) using the output buffer can actually reduce the processing time of the script significantly. I did a little benchmarking and my results agreed - even on a fairly small script that didn't do too much... Quote Link to comment Share on other sites More sharing options...
Jenk Posted February 27, 2007 Share Posted February 27, 2007 You can output headers where ever you like if you use ob_start and ob_end_flush. I used to reserve these for building my cms's as not so many would be in the cms for long periods so I thought it would not matter about server load and runtime etc. I read an article recently that suggest that if you have lots of output statements all over (echo, print_r etc.) using the output buffer can actually reduce the processing time of the script significantly. I did a little benchmarking and my results agreed - even on a fairly small script that didn't do too much... That's a code smell. You should not rely on this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.