Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Carlos Enrique Castañeda Gutiérrez13,886 Points
Question about header() and output_buffering
Hello, I have some doubts about using header()
1.- According to php documentation: "Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP". Mrs Alena use a big echo command to print the data, isn't considered an output?. In theory it shouldn't work but it does because something called output_buffering (I read on other question here). My question is: When is good idea to activate output_buffering, and when not? is it a good idea to keep it on even on production environment?
2.- Whe Alena didn't use exit command? because there weren't any code after the header?
3.- Is it my opinion but PHP can easily became messy?, for example let's say I have several php pages and uses several includes, and then I want to use header() to redirect to another page. It can be a hell to track the error, in this situation is it good idea to active the output_buffering to rid off the error. Is this a good use of that?