first_page

Error Handling in PHP5

It should not surprise me to not find the phrase “improved error handling in PHP” all over the Google-sphere. There is the “Error Handling in PHP” article from the Zend.com people, but here is written “improved” because it’s finally clear to me how to throw an error deep down in some function and feel confident that a callback function declared higher in the stack will catch this error.

This is extremely important, with my new RESTafarian focus, because, when PHP is being used as the backbone of a XML-over HTTP messaging stack, XML must be emitted always—even when exceptions are thrown. These are new features in PHP that make this certainty possible:

  • set_error_handler() has been around since PHP 4.0.1.
  • trigger_error() has been around since PHP 4.0.1.
  • die() has been around since PHP 3.So all of these ‘improvements’ have more to do with me that with PHP.

rasx()