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 trialKonrad Pilch
2,435 PointsPHP When do i use this ?
HI,
WHen do i use this code?
header("Location: index.php?error=".urlencode($error));
I see it quite frequenlty.
1 Answer
shawn stokes
5,651 Pointsit redirects you to the index with the error code. if you were on page B and a function or process generated an error, then error function would then redirect you to the index page with the error so that you could then generate code to display the error on the index page. although i would look at setting this to the session the less stuff passed through the URL the better.
Konrad Pilch
2,435 PointsKonrad Pilch
2,435 PointsWell, i know that it directs you to the location of index with the error typed above when somebding goes wrong but whats is the header? and when would you use this ? i mean