<?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/"
	>

<channel>
	<title>Gareth Rodger Blog</title>
	<atom:link href="http://garethrodger.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://garethrodger.com/blog</link>
	<description>The thoughts of a creative technologist from southern England.</description>
	<pubDate>Thu, 12 Feb 2009 18:43:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>New Twitter Account</title>
		<link>http://garethrodger.com/blog/2009/02/new-twitter-account/</link>
		<comments>http://garethrodger.com/blog/2009/02/new-twitter-account/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 03:30:14 +0000</pubDate>
		<dc:creator>Gareth Rodger</dc:creator>
		
		<category><![CDATA[Gareth Rodger]]></category>

		<category><![CDATA[garethrodger]]></category>

		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://garethrodger.com/blog/?p=18</guid>
		<description><![CDATA[Due to Twitter&#8217;s recent rise to fame, most of you, my friends, family and general public have probably heard of it so i&#8217;ve have set up a separate account to keep in touch with you all!
http://twitter.com/grodger
]]></description>
			<content:encoded><![CDATA[<p>Due to Twitter&#8217;s recent rise to fame, most of you, my friends, family and general public have probably heard of it so i&#8217;ve have set up a separate account to keep in touch with you all!</p>
<p><a title="Gareth Rodger Twitter Account" href="http://twitter.com/grodger" target="_blank">http://twitter.com/grodger</a></p>
]]></content:encoded>
			<wfw:commentRss>http://garethrodger.com/blog/2009/02/new-twitter-account/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP 5.3 - Static Class Abstraction</title>
		<link>http://garethrodger.com/blog/2008/11/php-53-static-class-abstraction/</link>
		<comments>http://garethrodger.com/blog/2008/11/php-53-static-class-abstraction/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 15:29:27 +0000</pubDate>
		<dc:creator>Gareth Rodger</dc:creator>
		
		<category><![CDATA[Gareth Rodger]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[garethrodger]]></category>

		<category><![CDATA[PHP 5.3]]></category>

		<category><![CDATA[static class]]></category>

		<guid isPermaLink="false">http://garethrodger.com/blog/?p=10</guid>
		<description><![CDATA[With the advent of PHP 5.3 just around the corner it&#8217;s time to start thinking how some of the new features will affect you.
In this post i&#8217;m going to focus on one of the smaller and more overlooked features, the improved static method/property access.
So to start let&#8217;s create a basic static class:

class product &#123;
	public static [...]]]></description>
			<content:encoded><![CDATA[<p>With the advent of PHP 5.3 just around the corner it&#8217;s time to start thinking how some of the new features will affect you.</p>
<p>In this post i&#8217;m going to focus on one of the smaller and more overlooked features, the improved static method/property access.</p>
<p>So to start let&#8217;s create a basic static class:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> product <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #990000;">static</span> <span style="color: #000088;">$name</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #990000;">static</span> <span style="color: #000088;">$colour</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #990000;">static</span> <span style="color: #000088;">$price</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #990000;">static</span> <span style="color: #000000; font-weight: bold;">function</span> getColour<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$tmp_colour</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'The colour is: '</span> <span style="color: #339933;">.</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$colour</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$tmp_colour</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>To access the properties and methods of this class prior to PHP 5.3 we&#8217;d do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Prior to PHP 5.3</span>
<span style="color: #990000;">print</span> product<span style="color: #339933;">::</span><span style="color: #000088;">$name</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print</span> product<span style="color: #339933;">::</span><span style="color: #000088;">$price</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print</span> product<span style="color: #339933;">::</span><span style="color: #004000;">getColour</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now the beauty of the feature in PHP 5.3 is that you can abstract the name of the class when referencing the static methods and properties:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// PHP 5.3</span>
<span style="color: #000088;">$prod_class</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'product'</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print</span> <span style="color: #000088;">$prod_class</span><span style="color: #339933;">::</span><span style="color: #000088;">$name</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print</span> <span style="color: #000088;">$prod_class</span><span style="color: #339933;">::</span><span style="color: #000088;">$price</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print</span> <span style="color: #000088;">$prod_class</span><span style="color: #339933;">::</span><span style="color: #004000;">getColour</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>See the benefit yet? If you need to switch in a new class with a new name it&#8217;s a three line change in the first code segment due to the hardcoded class name, whereas in the second segment it&#8217;s a one line change.</p>
<p>Scale this to a larger project with multiple static classes and lot&#8217;s of calls and it&#8217;s a nice little bit of abstraction.</p>
<p>There&#8217;s more to come on the PHP 5.3 update in future posts so stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://garethrodger.com/blog/2008/11/php-53-static-class-abstraction/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Gareth Rodger - New Blog - Foundations</title>
		<link>http://garethrodger.com/blog/2008/11/foundations/</link>
		<comments>http://garethrodger.com/blog/2008/11/foundations/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 13:28:05 +0000</pubDate>
		<dc:creator>Gareth Rodger</dc:creator>
		
		<category><![CDATA[Gareth Rodger]]></category>

		<category><![CDATA[Miscellaneous]]></category>

		<category><![CDATA[garethrodger]]></category>

		<guid isPermaLink="false">http://garethrodger.com/blog/?p=3</guid>
		<description><![CDATA[Welcome to this new blog, the focus of which will be educational articles on PHP, Flex and other &#8216;New Media&#8217; technologies.
Kind regards,
Gareth Rodger
]]></description>
			<content:encoded><![CDATA[<p>Welcome to this new blog, the focus of which will be educational articles on PHP, Flex and other &#8216;New Media&#8217; technologies.</p>
<p>Kind regards,</p>
<p>Gareth Rodger</p>
]]></content:encoded>
			<wfw:commentRss>http://garethrodger.com/blog/2008/11/foundations/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
