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 trialmichael lee
5,179 Pointswhat is the word throw mean?
I still don't understand what throw means, is it the same as return?
1 Answer
jamesjones21
9,260 PointsThrow is apart of the try and catch block, like for instance try database connection, if no connection throw an error. The error will then be caught in the catch block, where you will output a message of what the error is.
Hope this explanation helps? :)
cheers James
michael lee
5,179 Pointsmichael lee
5,179 Pointsthanks a lot, but what is the "new" mean in the "throw new"??
jamesjones21
9,260 Pointsjamesjones21
9,260 PointsIt means create a new instance of the object, which in PHP (a c language) it has its own predefined Exception class, so that will be passed into the function, so then it becomes an object, then we can call on the methods within that class.