<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Tue, 22 May 2012 13:58:23 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Jani Hartikainen's Blog: The "do X or die()" pattern must die]]></title>
      <guid>http://www.phpdeveloper.org/news/14868</guid>
      <link>http://www.phpdeveloper.org/news/14868</link>
      <description><![CDATA[<p>
<i>Jani Hartikainen</i> has a suggestion for all PHP developers out there - <a href="http://codeutopia.net/blog/2010/07/28/the-do-x-or-die-pattern-must-die/">stop using die()</a> for handling errors!
</p>
<blockquote>
What's the most common pattern for error handling you see in beginner's PHP code? - That's right, do_X() or die('do_X failed);. That's nice and all, as at least you have some sort of error handling, but I think this way of handling errors must go. There is no place for it in modern PHP code - it's the worst way to handle errors, not much better than not handling them at all.
</blockquote>
<p>
He talks about why <a href="http://php.net/die">die()</a> is so bad and some alternatives to it - <a href="http://php.net/trigger_error">trigger_error</a> (with a custom error handler) and <a href="http://php.net/Exceptions">exceptions</a>. When used correctly, these two can help your script correctly catch and handle errors without the mess of a die().
</p>]]></description>
      <pubDate>Thu, 29 Jul 2010 09:19:03 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPFreaks.com: or die() must die]]></title>
      <guid>http://www.phpdeveloper.org/news/12593</guid>
      <link>http://www.phpdeveloper.org/news/12593</link>
      <description><![CDATA[<p>
According to <a href="http://www.phpfreaks.com/blog/or-die-must-die">this new article</a> on the PHPFreaks.com site the use of "or die()" in scripts...must die!
</p>
<blockquote>
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. 
</blockquote>
<p>
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 <a href="http://php.net/trigger_error">trigger_error</a> and the exception handling built into PHP5 to correctly catch any potential errors a statement might throw.
</p>]]></description>
      <pubDate>Fri, 29 May 2009 10:28:37 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Brian Moon's Blog: The death of die()]]></title>
      <guid>http://www.phpdeveloper.org/news/12365</guid>
      <link>http://www.phpdeveloper.org/news/12365</link>
      <description><![CDATA[<p>
<i>Brian Moon</i> has <a href="http://brian.moonspot.net/dont-use-the-die-function">called for the death of die()</a>:
</p>
<blockquote>
Now, I have no actual authority to do so.  My PHP CVS karma does not extend that far.  And I doubt it will actually get removed despite it being nothing more than an alias for exit now. No, what I would like to call a death to is the usage of die such as [echoing out a message to the user instead of doing proper error handling].
</blockquote>
<p>
He points out a few perfectly viable alternatives like the <a href="http://www.php.net/exceptions">exception handlers</a>, the <a href="http://www.php.net/trigger_error">trigger_error</a> function and custom <a href="http://www.php.net/set_error_handler">error handlers</a>.
</p>]]></description>
      <pubDate>Fri, 17 Apr 2009 12:02:29 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Eirik Hoem's Blog: Dying with grace - PHP's register_shutdown_function]]></title>
      <guid>http://www.phpdeveloper.org/news/9808</guid>
      <link>http://www.phpdeveloper.org/news/9808</link>
      <description><![CDATA[<p>
<i>Eirik Hoem</i> has <a href="http://eirikhoem.wordpress.com/2008/03/15/dying-with-grace-phps-register_shutdown_function/">posted a new look</a> at a function that can be amazingly helpful when you have a script with issues that needs a little extra help cleaning up after itself - <a href="http://no2.php.net/register_shutdown_function">register_shutdown_function</a>.
</p>
<blockquote>
Scripts tend to die, and that's not usually nice. We do not want to show the user a fatal error nor a blank page (display errors off) . PHP has a function called <a href="http://no2.php.net/register_shutdown_function">register_shutdown_function</a> which lets us set up a function which is called at execution shutdown. What this means is that our function will be executed when our script is done executing / dying and PHP execution is about to shut down.
</blockquote>
<p>
He <a href="http://eirikhoem.wordpress.com/2008/03/15/dying-with-grace-phps-register_shutdown_function/">suggests</a> various things that can be done with the functionality, including checking for successful script execution (via a false variable that can be checked for success).
</p>]]></description>
      <pubDate>Mon, 17 Mar 2008 12:02:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Error Handling in PHP - Coding Defensively]]></title>
      <guid>http://www.phpdeveloper.org/news/4649</guid>
      <link>http://www.phpdeveloper.org/news/4649</link>
      <description><![CDATA[DevShed has <a href="http://www.devshed.com/c/a/PHP/Error-Handling-in-PHP-Coding-Defensively/">a new article</a> posted today dealing with error reporting in PHP applications.
<p>
<quote>
<i>
Since error handling is something that you should introduce (at least progressively) into your applications, in this article I'll explore some of the most common error checking methods available in PHP, in order to make web applications much more robust and reliable. 
<p>
The end result of this experience will be an illustrative list of hands-on examples that utilize different error handling methods, ranging in from using simple "die()" statements, to manipulating errors within an object-oriented context, by utilizing exceptions.
</i>
</quote>
<p>
They <a href="http://www.devshed.com/c/a/PHP/Error-Handling-in-PHP-Coding-Defensively/">cover</a> things like the basic die() statement, triggering errors in your code with the trigger_error() function, using the error handling in PEAR, and setting boolean flags to catch when things go wrong...]]></description>
      <pubDate>Thu, 12 Jan 2006 06:34:19 -0600</pubDate>
    </item>
  </channel>
</rss>

