News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Ole Markus' Blog:
Catching fatal errors in PHP
March 11, 2011 @ 09:16:42

Ole Markus has a new post today looking at how you can catch fatal errors in your PHP applications a bit more gracefully than the usual failure messages.

In dynamic languages like PHP [errors like E_ERROR and E_PARSE] happen all the time, for example when trying to call a method on a variable you assumed was an instance of a specific class, but which for some reason suddenly was not instantiated. Not only are they often not catched, but often it is also difficult to even know that they are occurring.

His solution comes in the form of a built-in PHP function, register_shutdown_function, that executes when the PHP process is shutting down - errors or not. It takes in a callback method that has access to an exception object. You can get lots of interesting information from this object and, as in his example, log it to a file for future investigation.

0 comments voice your opinion now!
catch fatal error registershutdownfunction exception zendlog


blog comments powered by Disqus

Similar Posts

PHPit.net: How to handle those pesky errors in PHP

Vexxhost.com: Top 5 new (and cool!) features in PHP5 that you probably haven't heard of

DevShed: Error Handling in PHP - Introducing Exceptions in PHP 5

Gonzalo Ayuso's Blog: Display errors on screen even with display errors = off with PHP

PHP-Coding-Practices.com: Try-Catch Syntax Weirdness


Community Events





Don't see your event here?
Let us know!


series interview voicesoftheelephpant introduction conference community list release tips symfony bugfix podcast deployment api framework threedevsandamaybe code zendserver language laravel

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework