Exceptions in PHP - Try/Catch or set_exception_handler?

后端 未结 3 1236
刺人心
刺人心 2020-12-23 10:29

I\'m developing some lower end code in my system that uses multiple child classes of the php exception class. Essentially I have the exceptions broken up to a few categorie

3条回答
  •  温柔的废话
    2020-12-23 11:07

    From the way it sounds, you will be using set_exception_handler. This will guarantee that all exceptions are handled in the exact same way. There are places to use the try/catch blocks in your application, say if you want to check for a single exception that does not necessarily need to be caught in the same way.

    As far as setting set_exception_handler, I'm not sure if you can set the function to be a method of an object unless it is a static method. It appears that is the case. There is more information at http://us2.php.net/set_exception_handler

提交回复
热议问题