<?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>lukebaker.org &#187; Programming</title>
	<atom:link href="http://lukebaker.org/archives/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://lukebaker.org</link>
	<description>lukebaker.org</description>
	<lastBuildDate>Tue, 08 Mar 2011 22:39:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Disc Golf Courses By County</title>
		<link>http://lukebaker.org/archives/2011/03/08/disc-golf-courses-by-county/</link>
		<comments>http://lukebaker.org/archives/2011/03/08/disc-golf-courses-by-county/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 22:39:20 +0000</pubDate>
		<dc:creator>Luke</dc:creator>
				<category><![CDATA[Disc Golf]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://lukebaker.org/?p=81</guid>
		<description><![CDATA[With a healthy blanket of snow still on the ground, I took on an indoor disc golf project this weekend.  I&#8217;ve been wondering about the distribution of golf courses across the country, so after downloading some data on disc golf courses I created a map of all the disc golf courses in the USA by [...]]]></description>
			<content:encoded><![CDATA[<p>With a healthy blanket of snow still on the ground, I took on an indoor disc golf project this weekend.  I&#8217;ve been wondering about the distribution of golf courses across the country, so after downloading some data on disc golf courses I created a map of all the disc golf courses in the USA by county.</p>
<p><a href="http://lukebaker.org/wordpress/wp-content/uploads/2011/03/courses-1280.jpg"><img class="alignnone size-full wp-image-83" style="border: 0px initial initial;" title="courses-650" src="http://lukebaker.org/wordpress/wp-content/uploads/2011/03/courses-650.jpg" alt="" width="650" height="412" /></a></p>
<p>&nbsp;</p>
<p><a href="http://lukebaker.org/wordpress/wp-content/counties_by_course_number.svg" target="_blank">Original SVG</a></p>
<p>Hat tip: <a href="http://flowingdata.com/2009/11/12/how-to-make-a-us-county-thematic-map-using-free-tools/" target="_blank">How to Make a US County Thematic Map Using Free Tools</a></p>
]]></content:encoded>
			<wfw:commentRss>http://lukebaker.org/archives/2011/03/08/disc-golf-courses-by-county/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SmugMug Tweaks</title>
		<link>http://lukebaker.org/archives/2007/12/17/smugmug-tweaks/</link>
		<comments>http://lukebaker.org/archives/2007/12/17/smugmug-tweaks/#comments</comments>
		<pubDate>Mon, 17 Dec 2007 18:02:02 +0000</pubDate>
		<dc:creator>Luke</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[SmugMug]]></category>

		<guid isPermaLink="false">http://lukebaker.org/archives/2007/12/17/smugmug-tweaks/</guid>
		<description><![CDATA[Lately, I&#8217;ve been working on some SmugMug tweaks to take advantage of their offer of a free lifetime account for developers who use their API. The first one was a quick hack which uploads some recent SmugMug photos to your Flickr account. This allows people who switched to SmugMug to still keep up with their [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://lukebaker.org/wordpress/wp-content/uploads/2007/12/screenshot7.png" alt="SmugMug Admin Rating Sample" align="right" /></p>
<p>Lately, I&#8217;ve been working on some <a href="http://www.smugmug.com/">SmugMug</a> tweaks to take advantage of their <a href="http://blogs.smugmug.com/don/2007/04/20/lifetime-free-pro-accounts-to-developers/">offer of a free lifetime account for developers who use their API</a>.  The first one was a quick hack which uploads some recent SmugMug photos to your <a href="http://flickr.com/">Flickr</a> account.  This allows people who switched to SmugMug to still keep up with their Flickr network.  More information is available on the <a href="http://lukebaker.org/projects/smugmug-tweaks/smugmug-upload-recent-to-flickr/">project&#8217;s page</a>.</p>
<p align="left">The second and more interesting one is some JavaScript that adds the ability for SmugMug users to rate their own photos.  This is the first of two projects to aid my work flow.  Eventually I want to be able to upload a bunch of photos in a private album, rate them, and then in one fell swoop move all photos with a rating higher than X to a public album.</p>
<p>I provide two installation options which both pull the script from my server and inject it into the pages.  This should allow for invisible upgrades.  Savvy or cautious users can install it other ways.</p>
<p>Another interesting aspect of this project is its integration with SmugMug&#8217;s API.   First, we&#8217;re using the API on SmugMug&#8217;s own site.  This isn&#8217;t the typical use case of a photo site&#8217;s API.  Secondly, the script gets proper API authorization behind the scenes, without asking the user for any information.  Provided that the user is already logged in to SmugMug&#8217;s site, then my script gains that user&#8217;s credentials when interacting with API.  This is not evident in the API docs and requires a bit of a hack.</p>
<p>Any users should be aware of security concerns whenever external JavaScript is inserted into your page.  Protect yourself as you see fit.</p>
]]></content:encoded>
			<wfw:commentRss>http://lukebaker.org/archives/2007/12/17/smugmug-tweaks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActiveRecord in PHP</title>
		<link>http://lukebaker.org/archives/2007/09/24/activerecord-in-php/</link>
		<comments>http://lukebaker.org/archives/2007/09/24/activerecord-in-php/#comments</comments>
		<pubDate>Mon, 24 Sep 2007 23:25:47 +0000</pubDate>
		<dc:creator>Luke</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://lukebaker.org/archives/2007/09/24/activerecord-in-php/</guid>
		<description><![CDATA[I&#8217;ve been meaning to release this code for quite some time. I&#8217;ve finally had a bit of time and motivation to sit down and take care of it. Ever since I started working with Ruby on Rails, I would cringe whenever I had to write yet more PHP code to do simple CRUD actions. Furthermore [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to release this code for quite some time.  I&#8217;ve finally had a bit of time and motivation to sit down and take care of it.  Ever since I started working with Ruby on Rails, I would cringe whenever I had to write yet more PHP code to do simple <acronym title="Create Retrieve Update Delete">CRUD</acronym> actions.  Furthermore I really enjoyed the Rails syntax that you use to interact with its implementation of the ActiveRecord pattern.  As such, I went forward and built a clone using PHP5.  So far it has been used for a few projects and has been a joy to use.</p>
<p>Props to my employer, <a href="http://www.gospelcommunications.org/">Gospel Communications</a>, who allowed me to spend some time on this during work hours, as well as give me full copyright of the code.</p>
<p>More information and documentation over on the <a href="http://lukebaker.org/projects/activerecord-in-php/">project&#8217;s home page.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://lukebaker.org/archives/2007/09/24/activerecord-in-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP and Named Parameters</title>
		<link>http://lukebaker.org/archives/2007/03/01/php-and-named-parameters/</link>
		<comments>http://lukebaker.org/archives/2007/03/01/php-and-named-parameters/#comments</comments>
		<pubDate>Fri, 02 Mar 2007 01:51:11 +0000</pubDate>
		<dc:creator>Luke</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://lukebaker.org/archives/2007/03/01/php-and-named-parameters/</guid>
		<description><![CDATA[Since working with Ruby on Rails, I&#8217;ve become much more conscious about how my code looks. Occasionally, when working with PHP there are things that are a part of the language that tend to make my code look ugly or just not very clear and succinct. One such case is when defining arrays, particularly nested [...]]]></description>
			<content:encoded><![CDATA[<p>Since working with Ruby on Rails, I&#8217;ve become much more conscious about how my code looks.  Occasionally, when working with PHP there are things that are a part of the language that tend to make my code look ugly or just not very clear and succinct.</p>
<p>One such case is when defining arrays, particularly nested associative arrays.  PHP makes working with arrays fairly handy, however I always shudder when I have to create / populate an array explicitly.  Some of the code I&#8217;m working with lately uses associative arrays as a way to have named parameters in PHP.  Here&#8217;s some example code that uses associative arrays in this way:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$p1</span> = <span class="kw2">new</span> Person<span class="br0">&#40;</span><span class="st0">&#8216;Luke Baker&#8217;</span>, </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;<a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;home_phone&#8217;</span> =&gt; <span class="st0">&#8217;555-5555&#8242;</span>, <span class="st0">&#8216;cell_phone&#8217;</span> =&gt; <span class="st0">&#8217;555-5551&#8242;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$p2</span> = <span class="kw2">new</span> Person<span class="br0">&#40;</span><span class="st0">&#8216;John Doe&#8217;</span>, </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp;<a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;cell_phone&#8217;</span> =&gt; <span class="st0">&#8217;555-5531&#8242;</span>, <span class="st0">&#8216;email&#8217;</span> =&gt; <span class="st0">&#8216;john@doe.com&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>Named parameters let us accept lots of different types of information, without splitting them up into individual parameters and having to remember which order the parameters are in.  I can handle home_phone, cell_phone, and email in the person constructor and the call to the constructor doesn&#8217;t have to worry about the order of parameters or filling in null values for information it doesn&#8217;t have.</p>
<p>The above example doesn&#8217;t look too ugly, but we also aren&#8217;t stretching the named parameters very much.  Here&#8217;s a slightly messier example:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$p3</span> = <span class="kw2">new</span> Person<span class="br0">&#40;</span><span class="st0">&quot;John Calvin&quot;</span>, <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;dates&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;birth&#8217;</span> =&gt; <span class="st0">&#8216;July 10, 1509&#8242;</span>, <span class="st0">&#8216;death&#8217;</span> =&gt; <span class="st0">&#8216;May 27, 1564&#8242;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>We could break it into different lines, which doesn&#8217;t look too shabby:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$p3</span> = <span class="kw2">new</span> Person<span class="br0">&#40;</span><span class="st0">&quot;John Calvin&quot;</span>, <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="st0">&#8216;dates&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;birth&#8217;</span> =&gt; <span class="st0">&#8216;July 10, 1509&#8242;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;death&#8217;</span> =&gt; <span class="st0">&#8216;May 27, 1564&#8242;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>Another option, might be to use <a href="http://json.org/">JSON</a> to represent that associative array.  We could have our constructor decode the second parameter from JSON if it looks like it might be JSON.  Once it is decoded, we&#8217;re back to an array representation in PHP, which is what we started with.  In other words, we can easily allow our constructor to accept either JSON or an array as the second parameter.  Then we could write the call the to constructor as follows:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$p3</span> = <span class="kw2">new</span> Person<span class="br0">&#40;</span><span class="st0">&quot;John Calvin&quot;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="st0">&#8216;{&quot;dates&quot; : {&quot;birth&quot; : &quot;July 10, 1509&quot;, &quot;death&quot; : &quot;May 27, 1564&quot;}}&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>Maybe I&#8217;m silly, but I like the look of the JSON example a bit better.  I certainly won&#8217;t be using JSON everywhere I declare arrays, but here and there I find it useful.  What do you think, is it worthwhile to support JSON in this way?</p>
]]></content:encoded>
			<wfw:commentRss>http://lukebaker.org/archives/2007/03/01/php-and-named-parameters/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The static keyword in PHP5</title>
		<link>http://lukebaker.org/archives/2007/02/11/the-static-keyword-in-php5/</link>
		<comments>http://lukebaker.org/archives/2007/02/11/the-static-keyword-in-php5/#comments</comments>
		<pubDate>Mon, 12 Feb 2007 03:01:44 +0000</pubDate>
		<dc:creator>Luke</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://lukebaker.org/archives/2007/02/11/the-static-keyword-in-php5/</guid>
		<description><![CDATA[With PHP5, PHP introduced some more robust object oriented capabilities to the language. I&#8217;ve been diving into this quite a bit lately and learning a lot. I figured all the stuff I discovered about the static keyword would be enough fodder for a post. Most of this information can probably be gleamed straight from the [...]]]></description>
			<content:encoded><![CDATA[<p>With PHP5, PHP introduced some more robust object oriented capabilities to the language.  I&#8217;ve been diving into this quite a bit lately and learning a lot.  I figured all the stuff I discovered about the static keyword would be enough fodder for a post.  Most of this information can probably be gleamed <a href="http://www.php.net/manual/en/language.oop5.static.php">straight from the docs</a>, but I for one didn&#8217;t really soak up the denseness of the documentation my first few times around.</p>
<p><strong>Static Members</strong></p>
<p>What isn&#8217;t immediately obvious, is that static members are shared among all the instances of the class that has the static member.  In other words, it is like a global variable for that class and instances of that class.  While you can&#8217;t access a static member directly from an instantiation of the class, you can create methods that access or manipulate the static member.  Time for a quick example.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">class</span> Foo <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <a href="http://www.php.net/static"><span class="kw3">static</span></a> <span class="re0">$var</span> = <span class="nu0">0</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">function</span> increment<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> self::<span class="re0">$var</span>++; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">function</span> get<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw1">return</span> self::<span class="re0">$var</span>; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$f1</span> = <span class="kw2">new</span> Foo<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$f1</span>-&gt;<span class="me1">get</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; &nbsp;<span class="co1">// returns 0</span></div>
</li>
<li class="li1">
<div class="de1">Foo::<span class="re0">$var</span>; <span class="co1">// returns 0</span></div>
</li>
<li class="li2">
<div class="de2"><span class="re0">$f1</span>-&gt;<span class="me1">increment</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$f2</span> = <span class="kw2">new</span> Foo<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$f2</span>-&gt;<span class="me1">get</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; &nbsp;<span class="co1">// returns 1</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$f2</span>-&gt;<span class="me1">increment</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$f1</span>-&gt;<span class="me1">get</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; &nbsp;<span class="co1">// returns 2</span></div>
</li>
<li class="li2">
<div class="de2">Foo::<span class="re0">$var</span>; <span class="co1">// returns 2</span></div>
</li>
</ol>
</div>
<p>Now, the other interesting find is that the static member is global not only to that class and instances of that class, but also all sub-classes and instances of those sub-classes.  You can prevent this propagation down inheritance tree, by declaring the static member as private or by redeclaring that static member inside the sub-classes, as well as the methods that work on the static method.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">class</span> Foo <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <a href="http://www.php.net/static"><span class="kw3">static</span></a> <span class="re0">$var</span> = <span class="nu0">0</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">function</span> increment<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> self::<span class="re0">$var</span>++; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">function</span> get<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw1">return</span> self::<span class="re0">$var</span>; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">class</span> Bar <span class="kw2">extends</span> Foo <span class="br0">&#123;</span> <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">Foo::<span class="re0">$var</span>++;</div>
</li>
<li class="li1">
<div class="de1">Bar::<span class="re0">$var</span>; &nbsp;<span class="co1">// returns 1</span></div>
</li>
</ol>
</div>
<p><strong>Static Methods</strong></p>
<p>The main area that I got hung up with static methods was using inherited static method calls.  For the work I was doing, I wanted to be able to call a static method and within the static method know which class this method was called on.  Unfortunately, everything I tried didn&#8217;t work.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">class</span> Foo <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <a href="http://www.php.net/static"><span class="kw3">static</span></a> <span class="kw2">function</span> get_my_class<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw1">return</span> <a href="http://www.php.net/get_class"><span class="kw3">get_class</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span>; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">function</span> get_my_class2<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw1">return</span> <a href="http://www.php.net/get_class"><span class="kw3">get_class</span></a><span class="br0">&#40;</span><span class="re0">$this</span><span class="br0">&#41;</span>; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="kw2">class</span> Bar <span class="kw2">extends</span> Foo <span class="br0">&#123;</span><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">Bar::<span class="me2">get_my_class</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; &nbsp;<span class="co1">// returns &#8216;Foo&#8217;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$b</span> = <span class="kw2">new</span> Bar<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$b</span>-&gt;<span class="me1">get_my_class2</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; &nbsp;<span class="co1">// returns &#8216;Bar&#8217; </span></div>
</li>
</ol>
</div>
<p>It turns out that static methods belong to the class in which they&#8217;re defined and they have no clue where they got called from.  Similarly, the same idea can be applied when thinking about static members.  The class that has the actual code, determines what variable is affected.  Consider one last example:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">class</span> Foo <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <a href="http://www.php.net/static"><span class="kw3">static</span></a> <span class="re0">$var</span> = <span class="nu0">0</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">function</span> increment<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> self::<span class="re0">$var</span>++; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">function</span> get<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw1">return</span> self::<span class="re0">$var</span>; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">class</span> Bar <span class="kw2">extends</span> Foo <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <a href="http://www.php.net/static"><span class="kw3">static</span></a> <span class="re0">$var</span> = <span class="nu0">23</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">function</span> increment<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> self::<span class="re0">$var</span>++; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="re0">$f</span> = <span class="kw2">new</span> Foo<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$b</span> = <span class="kw2">new</span> Bar<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$b</span>-&gt;<span class="me1">get</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; <span class="co1">// returns 0 (Foo)</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$b</span>-&gt;<span class="me1">increment</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; &nbsp;<span class="co1">// increment Bar&#8217;s $var</span></div>
</li>
<li class="li1">
<div class="de1">Bar::<span class="re0">$var</span>; <span class="co1">// returns 24 (Bar)</span></div>
</li>
<li class="li2">
<div class="de2"><span class="re0">$b</span>-&gt;<span class="me1">get</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; <span class="co1">// returns 0</span></div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://lukebaker.org/archives/2007/02/11/the-static-keyword-in-php5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.492 seconds -->

