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
Darrel Lyons
2,991 PointsExit(); or Die();
Whenever i use exit(); or die();, the backgrounds are always white. How to i make it so it stays as the original background?
EDIT: I've sorted it. I placed the PHP underneath my link to the stylesheet.
1 Answer
James Andrews
7,245 Pointsdon't use exit or die. Exit is usually used when you want to do something like
echo json_encode($jsonArray);
die()
is really meant for command line php scripts. Using it on web pages is bad.
you should be using try /catch blocks with exceptions to handle problems in php and relay them to the user.
try
{
if(!$success) throw new Exception("Something went wrong");
}
catch(Exception $e)
{
echo $e->getMessage();
}