Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
What happens when the system is unable to connect to the database? Whenever your code relies on an external system, there's always the chance that something could go wrong. These are known as exceptions and any code connecting to an external system needs to handle them.
Exception Handling
Although exception handling works in both PHP 5 and PHP 7, they will display slightly different exceptions. This means that the exact error text displayed could be different then what you see in the video, depending on which version of PHP you are running. This does not affect functionality and you should be able to follow along in any version of PHP 5 or above. PHP 7 introduced more precise exceptions. Instead of just throwing a generic exception, PHP 7 will also specify if this is an ArithmeticError, DivisionByZeroError, AssertionError, ParseError, or TypeError.
To learn more about the changes in PHP 7, check out our
Introduction to PHP 7 Workshop
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Riki Tiilikainen
4,042 Points2 Answers
-
Siraj Khan
3,451 Points4 Answers
-
Attila Balog
5,217 Points2 Answers
-
Matt Corby
2,385 PointsWhy do we need the Exception $e parameter to the catch() if we don't use it?
Posted by Matt CorbyMatt Corby
2,385 Points0 Answers
-
Hector F.
27,464 Points1 Answer
-
MOD
Jonathan Grieve
Treehouse Moderator 91,254 Points3 Answers
-
Boaoboa RLlaof
94 Points2 Answers
-
Mark Berning
11,326 PointsMisspelled db name still connects successfully on my local machine (not using Workspaces).
Posted by Mark BerningMark Berning
11,326 Points3 Answers
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up