<?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>PHP Software Developing &#187; Error handling</title>
	<atom:link href="http://www.phpdeveloping.co.za/category/error-handling/feed" rel="self" type="application/rss+xml" />
	<link>http://www.phpdeveloping.co.za</link>
	<description>for the love of PHP Development</description>
	<lastBuildDate>Tue, 29 Sep 2009 15:38:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>When a function doesn&#8217;t exist</title>
		<link>http://www.phpdeveloping.co.za/error-handling/when-a-function-doesnt-exist.html</link>
		<comments>http://www.phpdeveloping.co.za/error-handling/when-a-function-doesnt-exist.html#comments</comments>
		<pubDate>Thu, 23 Jul 2009 14:34:02 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Error handling]]></category>
		<category><![CDATA[functions]]></category>

		<guid isPermaLink="false">http://www.phpdeveloping.co.za/?p=50</guid>
		<description><![CDATA[Sometimes we develop PHP scripts that requires other 3rd party libraries or makes use of PHP4 or PHP5 specific functions.  What we then forget is that when we upload it to a server with PHP4 on and we developed for PHP5, we&#8217;re going to end up with a lot of &#8220;function not found&#8221; errors.
Yes, [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes we develop PHP scripts that requires other 3rd party libraries or makes use of PHP4 or PHP5 specific functions.  What we then forget is that when we upload it to a server with PHP4 on and we developed for PHP5, we&#8217;re going to end up with a lot of &#8220;function not found&#8221; errors.</p>
<p>Yes, PHP4 is old news, and everyone should be using PHP5 by now, but there are still a lot of times I come across the need for PHP4 development.</p>
<p>What I&#8217;ve started doing is making PHP4 equivalent functions.  But this is not what this post is about, what I want to tell you about is the <a target=_blank href="http://www.php.net/manual/en/function.function-exists.php">function_exists</a> function.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span>’FUNCTION_CALL’<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  FUNCTION_CALL<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You can define your own function by doing this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span>’FUNCTION_CALL’<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">function</span> FUNCTION_CALL<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;this function does something&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The above will only create your own function is the function doesn&#8217;t already exist.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpdeveloping.co.za/error-handling/when-a-function-doesnt-exist.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error suppression operator</title>
		<link>http://www.phpdeveloping.co.za/error-handling/error-suppression-operator.html</link>
		<comments>http://www.phpdeveloping.co.za/error-handling/error-suppression-operator.html#comments</comments>
		<pubDate>Wed, 22 Jul 2009 15:50:35 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Error handling]]></category>

		<guid isPermaLink="false">http://www.phpdeveloping.co.za/?p=16</guid>
		<description><![CDATA[In PHP the error suppression operator is the @ sign.  Whenever you put this sign in front of an expression, it doesn&#8217;t show up any errors that the expression generates.  This is a handy feature if you don&#8217;t want errors showing up while the script is running.  The problem with this though [...]]]></description>
			<content:encoded><![CDATA[<p>In PHP the error suppression operator is the @ sign.  Whenever you put this sign in front of an expression, it doesn&#8217;t show up any errors that the expression generates.  This is a handy feature if you don&#8217;t want errors showing up while the script is running.  The problem with this though is that a lot of people are using it incorrectly.  It might not always be a problem, but because the suppression operator is rather slow when it comes to performance, it can slow down your script.  </p>
<p>So, if performance is an issue, have a look at these <a href="http://michelf.com/weblog/2005/bad-uses-of-the-at-operator/" target=_blank>examples</a> on how to go about not using the suppression operator but still getting the same affect.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$albus</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$albert</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$albus</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span> <span style="color: #000088;">$albert</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span></pre></div></div>

<p>is the same as</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$albert</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #000088;">$albus</span><span style="color: #339933;">;</span></pre></div></div>

<p>Another method would be to use the variable as a reference varilable:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$albert</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$albus</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.phpdeveloping.co.za/error-handling/error-suppression-operator.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
