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.
Aaron Uusitalo4,229 Points
Why don't the echo statements before the header method cause redirect failure?
We are warned not to send anything to the browser, even a blank line, lest it be interpreted as a header response and sabotage our redirect.
Why don't the echo statements at the start of our scrip cause this problem?
Andy Goodman14,207 Points
I would like an answer to this question too.
The code clearly shows a number of echo statements in process.php above the header redirect, but the redirect works fine. One of the questions in the next section has an echo statement before the redirect and the correct answer is that you will see the echoed text, but with an error warning for the redirect.
Can someone explain this clearly please?
Steven Jackson11,318 Points
They definitely said that even a blank line will cause the re-direct to fail. This looks like an issue with workspaces. I've been using VSCode on this project and the echo statements caused an error. After all an echo creates more than a blank line. Once removed the redirect works properly in the VSCode environment. When I tested it in workspaces the redirect happens regardless of whether or not there is an echo statement. Has to be a bug with workspaces. Even though workspace is pretty amazing for an in-browser app it still has a few bugs. Take the time to set up a dev environment in VSCode or another appropriate IDE. You'll definitely thank yourself later.
Hope this helps!