<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>evardsson.com: stuff that w0rks &#187; Debugging</title>
	<atom:link href="http://www.evardsson.com/blog/tag/debugging/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.evardsson.com/blog</link>
	<description>tweaks and hacks, php, python, music, home and ???</description>
	<lastBuildDate>Thu, 29 Jul 2010 19:25:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Error Handling and the PHP @ Operator</title>
		<link>http://www.evardsson.com/blog/2009/06/07/error-handling-and-the-php-operator/</link>
		<comments>http://www.evardsson.com/blog/2009/06/07/error-handling-and-the-php-operator/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 23:46:56 +0000</pubDate>
		<dc:creator>Sjan Evardsson</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Debugging]]></category>

		<guid isPermaLink="false">http://www.evardsson.com/blog/?p=369</guid>
		<description><![CDATA[I have been trying to debug a plugin for WordPress (Shorten2Ping &#8211; I will keep plugging this because I think it is so nifty!) and I was running into a problem where the plugin would silently fail with nothing in the logs, no error printing to screen, just dead silence. I turned on display_errors in [...]]]></description>
			<content:encoded><![CDATA[<p>I have been trying to debug a plugin for WordPress (<a href="http://www.samuelaguilera.com/archivo/shorten2ping-notifies-pingfm-bitly.xhtml">Shorten2Ping</a> &#8211; I will keep plugging this because I think it is so nifty!) and I was running into a problem where the plugin would silently fail with nothing in the logs, no error printing to screen, just dead silence.</p>
<p>I turned on display_errors in php.ini for a while to see if anything would show up. Still nothing. So I started to look through the file again. I knew it was getting as far as creating the short url in <a href="http://bit.ly">bit.ly</a> before it died, but nothing was getting entered into the database. So I started through the <code>make_bitly_url()</code> function and what jumped out and slapped me in the face? <code>$json = @json_decode($response,true);</code> That little, innocuous-looking @ was gulping the error message from a fatal error! (Namely, &#8220;<code>Call to undefined function json_decode()</code>&#8220;). It turns out that I had PHP compiled with &#8211;disable-json, which is default for Gentoo <em>unless</em> you have json in your USE flags.</p>
<p>According to the PHP docs for the Error Control Operator @:</p>
<blockquote>
<p id="line78">Currently the &#8220;@&#8221; error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. Among other things, this means that if you use &#8220;@&#8221; to suppress errors from a certain function and either it isn&#8217;t available or has been mistyped, the script will die right there with no indication as to why.</p>
</blockquote>
<p>So, if you really must supress error messages, do so, but do so with care. In the case where a suppressed error may be fatal (as in this case) be sure to add documentation to that effect. As in &#8220;If this dies a silent death it may very well be that you do not have function xyz() enabled.&#8221;</p>
<p>And, note to self, when debugging PHP, the first thing to do is look for and remove the error control operator.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Error+Handling+and+the+PHP+%40+Operator+http://hdiws.th8.us" title="Post to Twitter"><img class="nothumb" src="http://www.evardsson.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://buzz.yahoo.com/submit?submitUrl=http://www.evardsson.com/blog/2009/06/07/error-handling-and-the-php-operator/&amp;submitHeadline=Error+Handling+and+the+PHP+%40+Operator" title="Post to Yahoo Buzz"><img class="nothumb" src="http://www.evardsson.com/blog/wp-content/plugins/tweet-this/icons/tt-buzz.png" alt="Post to Yahoo Buzz" /></a> <a class="tt" href="http://buzz.yahoo.com/submit?submitUrl=http://www.evardsson.com/blog/2009/06/07/error-handling-and-the-php-operator/&amp;submitHeadline=Error+Handling+and+the+PHP+%40+Operator" title="Post to Yahoo Buzz">Buzz This Post</a> <a class="tt" href="http://delicious.com/post?url=http://www.evardsson.com/blog/2009/06/07/error-handling-and-the-php-operator/&amp;title=Error+Handling+and+the+PHP+%40+Operator" title="Post to Delicious"><img class="nothumb" src="http://www.evardsson.com/blog/wp-content/plugins/tweet-this/icons/tt-delicious.png" alt="Post to Delicious" /></a> <a class="tt" href="http://delicious.com/post?url=http://www.evardsson.com/blog/2009/06/07/error-handling-and-the-php-operator/&amp;title=Error+Handling+and+the+PHP+%40+Operator" title="Post to Delicious">Delicious</a> <a class="tt" href="http://digg.com/submit?url=http://www.evardsson.com/blog/2009/06/07/error-handling-and-the-php-operator/&amp;title=Error+Handling+and+the+PHP+%40+Operator" title="Post to Digg"><img class="nothumb" src="http://www.evardsson.com/blog/wp-content/plugins/tweet-this/icons/tt-digg.png" alt="Post to Digg" /></a> <a class="tt" href="http://digg.com/submit?url=http://www.evardsson.com/blog/2009/06/07/error-handling-and-the-php-operator/&amp;title=Error+Handling+and+the+PHP+%40+Operator" title="Post to Digg">Digg This Post</a> <a class="tt" href="http://ping.fm/ref/?method=microblog&amp;title=Error+Handling+and+the+PHP+%40+Operator&amp;link=http://www.evardsson.com/blog/2009/06/07/error-handling-and-the-php-operator/" title="Post to Ping.fm"><img class="nothumb" src="http://www.evardsson.com/blog/wp-content/plugins/tweet-this/icons/tt-ping.png" alt="Post to Ping.fm" /></a> <a class="tt" href="http://ping.fm/ref/?method=microblog&amp;title=Error+Handling+and+the+PHP+%40+Operator&amp;link=http://www.evardsson.com/blog/2009/06/07/error-handling-and-the-php-operator/" title="Post to Ping.fm">Ping This Post</a> <a class="tt" href="http://reddit.com/submit?url=http://www.evardsson.com/blog/2009/06/07/error-handling-and-the-php-operator/&amp;title=Error+Handling+and+the+PHP+%40+Operator" title="Post to Reddit"><img class="nothumb" src="http://www.evardsson.com/blog/wp-content/plugins/tweet-this/icons/tt-reddit.png" alt="Post to Reddit" /></a> <a class="tt" href="http://reddit.com/submit?url=http://www.evardsson.com/blog/2009/06/07/error-handling-and-the-php-operator/&amp;title=Error+Handling+and+the+PHP+%40+Operator" title="Post to Reddit">Reddit</a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.evardsson.com/blog/2009/06/07/error-handling-and-the-php-operator/&amp;title=Error+Handling+and+the+PHP+%40+Operator" title="Post to StumbleUpon"><img class="nothumb" src="http://www.evardsson.com/blog/wp-content/plugins/tweet-this/icons/tt-su.png" alt="Post to StumbleUpon" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://www.evardsson.com/blog/2009/06/07/error-handling-and-the-php-operator/&amp;title=Error+Handling+and+the+PHP+%40+Operator" title="Post to StumbleUpon">Stumble This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.evardsson.com/blog/2009/06/07/error-handling-and-the-php-operator/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
