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 trialScott Dunstan
12,517 PointsHeader() not working?
I couldn't for the life of me figure out why header() didn't seem to be functioning - turns out it was because I had a blank line at the top of the contact-process.php page. That blank line, and in fact any blank lines in that code constitutes output and renders the header() function ineffective on account of there being a rule that the code cannot produce ANY output BEFORE you call the header() function!
3 Answers
Scott Dunstan
12,517 PointsYep, line 1 was blank, and my "<?php" tag started on line 2.
Jason Anello
Courses Plus Student 94,610 PointsOk, that makes sense based on what else I've read. After the php tag you should be able to do other processing and have blank lines before the header.
Scott Dunstan
12,517 PointsCool, thanks Jason.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 Pointsdo you mean that you had a blank line before your opening php tag?
I think it's ok to have blank lines within the php script.