Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a Basic PHP Website (2018) Adding a Basic Form Redirecting After a Form Submission

Carlos Enrique Castañeda Gutiérrez
Carlos Enrique Castañeda Gutiérrez
13,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?

Thanks