News Feed
Sections




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

PHPFreaks.com:
or die() must die
May 29, 2009 @ 10:28:37

According to this new article on the PHPFreaks.com site the use of "or die()" in scripts...must die!

I see it all the time, and I see people telling other people to do that all the time. It's plain simply bad practice and it's time that people start to understand this. When I confront people with it they usually say something along the lines of "oh, but it's just for debugging purposes". Okay, so I tend to put echo and var_dump() statements in my code for debugging as well. However, this is not the same.

They list several reasons why the "or die trick" is a bad idea including the non-catchable error that's thrown and that there's no control over where the error message from die goes. As a better alternative, they suggest using trigger_error and the exception handling built into PHP5 to correctly catch any potential errors a statement might throw.

1 comment voice your opinion now!
exception handling error die


blog comments powered by Disqus

Similar Posts

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

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

Three Devs & A Maybe Podcast: Exception and Error Handling

Daniel Cousineau's Blog: Quickie: Module-specific Error Controllers in Zend Framework (1.5)

Melvin Rivera's Blog: Creating a custom WordPress database error page


Community Events

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


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

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