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 trialJiri Stepanek
10,740 PointsMoving through pages
Hi, how can you move to a different page in PHP? Like in HTML you have to do <a href="hello.html">HI</a> and click to it. I wanna do the same but without that click. If it's possible, with no framework. TY ;)
2 Answers
Jeff Lemay
14,268 PointsYou can use php's header function.
<?php
header('Location: /example/path/here.php');
exit;
?>
Jiri Stepanek
10,740 Pointsthanks Jeff, that works ;)
Jeff Lemay
14,268 PointsJeff Lemay
14,268 PointsDocumentation
The biggest struggle I had with this in the past was, you cannot have anything output to the page before you call this function. So if you have a space or empty line at the top of your document before you open your php tag and call the header function, the function will fail.