Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
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 upRelated 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