Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed PHP Standards and Best Practices!
You have completed PHP Standards and Best Practices!
Preview
Exceptions are different from errors. Exceptions can easily be caught and handled separately on a case-by-case basis, whereas catching errors can only be done application-wide.
This video doesn't have any notes.
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
The core itself might not use exceptions
much, but
0:00
they are available if you wish to use them
in your own code.
0:01
And you'll certainly run into them using
components or frameworks.
0:03
The problem with giving falsy values is
that you have to go looking for a mistake
0:07
and check the documentation to see which
method provides the error message.
0:11
It's be much better to have an exception
thrown at you to make it
0:14
extremely obvious.
0:17
Let's take a look at how we can throw
various types of an exception from
0:19
a function and have PHP react differently
to each of them.
0:22
If we look in the workspace we'll see a
couple of files there which you
0:25
should recognize already from composer.
0:27
We open the index.php.
0:29
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