News Feed
Sections




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

Alexander Netkachev's Blog:
PHP coding tip Convert notices and warnings into Exceptions
October 18, 2006 @ 07:19:54

Exceptions and warnings can be tossed out from your code at some odd locations sometimes. There's a few options that you have when they jump out, including pushing them out to an error log or just ignoring them completely. Alexander Netkachev has a different solutions, though - handling them with something already built into PHP, using exception reporting.

This coding tip demonstrates how to deal with PHP core notices and warning (aka recoverable errors) in the exception way, using try/catch statement.

IT's a simple idea, but it can definitely help you keep all of you errors in one place. The sample code he gives shows both a basic idea of the solution and a bit more complex example, providing more detailed messages for different exception types.

0 comments voice your opinion now!
warnings notices exceptions convert handling try catch warnings notices exceptions convert handling try catch


blog comments powered by Disqus

Similar Posts

Kenny Meyers' Blog: How CodeIgniter Works (Video from EECI 2010)

Jani Hartikainen's Blog: The "do X or die()" pattern must die

DevShed: Error Handling for Dynamic Twitter Signature Images with PHP

Volker Dusch: Errors will be fixed. Warnings will be 'looked at'

Jani Hartikainen's Blog: How to use built-in SPL exception classes for better error handling


Community Events

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


xdebug php7 release extension laravel example voicesoftheelephpant unittest install interview opinion version introduction podcast api framework series community library language

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