Jump to content

Exception Handling and Exception Class


random1

Recommended Posts

How do you create your own Exception class in PHP?

 

My base programming language is Java, I can do it in that but I'm still pretty new PHP.

 

Can you create you an Exception class that catches it's own exceptions e.g. 'CustomException cex' ?

 

Also how do I make that code available to all other pages and classes in my project?

Link to comment
Share on other sites

And parent::__destruct if you override the destructor :)

 

You don't need to REPLACE the exception class - just extend it. Don't re-make it's existing methods unless you need to do something totally different. If it's only a little different, you can probably still use the existing method within one of your own

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.