<?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, 21 May 2013 09:34:06 -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>
  </channel>
</rss>
