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


Michael Perry
Michael Perry
1,976 Points

Question from quiz re: PHP header() function

In one of the quizzes in the "Build a Basic PHP Website" course, it asks what will happen when the following code is executed:


echo "Hello World!";

header("Location: newfile.php");

The answer is "Hello World! and a Warning," but when I try this code in the website I've been building in the course, it redirects me to the new page and doesn't give any warning or display "Hello World".

So why is this the answer? Is my browser hiding a warning from me?

1 Answer

Your browser may be hiding the warning... or, more likely the PHP installation is set up a little differently. On development servers PHP is usually set to show warnings - because the programmers can use them, but on production servers the setting is usually turned off so that normal website visitors aren't bothered by them.