<?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>Full On Design &#187; error handling</title>
	<atom:link href="http://www.fullondesign.co.uk/tag/error-handling/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fullondesign.co.uk</link>
	<description>Design &#38; Web Technologies</description>
	<lastBuildDate>Sun, 30 Oct 2011 21:37:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Handling Errors In PHP</title>
		<link>http://www.fullondesign.co.uk/coding/php/736-handling-errors-in-php.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/736-handling-errors-in-php.htm#comments</comments>
		<pubDate>Wed, 03 Jun 2009 18:44:14 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[error handling]]></category>
		<category><![CDATA[php class]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=736</guid>
		<description><![CDATA[Handling errors in PHP can be quite a handful at times. Here is a really simple PHP class which I use to manage errors: If you are looking to fully integrate a script similar to the above, there is a really good post regarding the set_error_handler() function on Tinsology ( PHP Error Handling ).]]></description>
			<content:encoded><![CDATA[<p>Handling errors in PHP can be quite a handful at times. Here is a really simple PHP class which I use to manage errors:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
/*
errors class - Helps management of errors in a script.

@version
	1.0
@author
	Mike Rogers (FullOnDesin.co.uk)
@last updated
	03 June 2009
@usage
	You are free to share, modify and use this code for commercial or non-commercial uses.
	Please give a link back (to http://www.fullondesign.co.uk/ ) if you can, but you don't have you.
	You use this at your own risk.
*/
class errors {
	var $errors_data;

	/*
	Add the error from $new_error into an array of errors.

	@param
		$new_error	string The text related to your error.
	@return:
		True - Error has been Added
	@example
		add_error('Username is Incorrect');
	*/
	public function add_error($new_error){
		$this-&gt;errors_data[] = $new_error;
		return TRUE;
	}

	/*
		Outputs the errors.

	@param
		None
	@return:
		- A div (ID - error) which contains the errors.
		NULL - No errors
	@example
		echo output_errors();
	*/
	public function output_errors(){
		if(is_array($this-&gt;errors_data)){
			// Cycle through the errors.
			foreach($this-&gt;errors_data as $error)	{
				$return .= '&lt;p&gt;'.$error.'&lt;/p&gt;';
			}
		// Add it to the error div
		return '&lt;div id=&quot;error&quot;&gt;'.$return.'&lt;/div&gt;';
		}
		return NULL;
	}
}

// @Example - creating the class:
$errors = new errors;

// @Example - Add an error
$errors-&gt;add_error('Username is incorrect');

// @Example - Return the errors
echo $errors-&gt;output_errors();
?&gt;</pre>
<p>If you are looking to fully integrate a script similar to the above, there is a really good post regarding the <a href="http://uk3.php.net/manual/en/function.set-error-handler.php">set_error_handler()</a> function on <a href="http://tinsology.net/2009/04/php-error-handling/">Tinsology ( PHP Error Handling )</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/736-handling-errors-in-php.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: basic
Database Caching 1/11 queries in 0.004 seconds using disk: basic
Object Caching 200/221 objects using disk: basic

Served from: www.fullondesign.co.uk @ 2012-02-04 09:02:03 -->
