<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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>Comments on: Introduction to classes</title>
	<atom:link href="http://www.guru.net.nz/blog/tutorials/intro-to-classes/feed" rel="self" type="application/rss+xml" />
	<link>http://www.guru.net.nz/blog</link>
	<description>Random stuff from a Dunedin (NZ) based web developer, beer drinker and dad</description>
	<lastBuildDate>Sat, 04 Feb 2012 17:52:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: DroBuddy</title>
		<link>http://www.guru.net.nz/blog/tutorials/intro-to-classes#comment-531</link>
		<dc:creator>DroBuddy</dc:creator>
		<pubDate>Sat, 11 Jul 2009 23:47:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.guru.net.nz/blog/?page_id=224#comment-531</guid>
		<description>Thanks for the tutorial... This is one of the best ones I&#039;ve been able to find and really helps clarify a lot of the issues. I&#039;m still a lil&#039; confused, but not nearly as much as I was prior to reading this!

If only someone would take the time to create some good video tuts on this... God, it would make this all so much easier. 

If you are interested in making a screencast on OOPHP, I would truly appreciate it and would be more than glad to put it on WebDevelopmentVideos.com with a link back to your site... Send me an e-mail if you&#039;re interested.

And, thanks again! Peace.</description>
		<content:encoded><![CDATA[<p>Thanks for the tutorial&#8230; This is one of the best ones I&#8217;ve been able to find and really helps clarify a lot of the issues. I&#8217;m still a lil&#8217; confused, but not nearly as much as I was prior to reading this!</p>
<p>If only someone would take the time to create some good video tuts on this&#8230; God, it would make this all so much easier. </p>
<p>If you are interested in making a screencast on OOPHP, I would truly appreciate it and would be more than glad to put it on WebDevelopmentVideos.com with a link back to your site&#8230; Send me an e-mail if you&#8217;re interested.</p>
<p>And, thanks again! Peace.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maik</title>
		<link>http://www.guru.net.nz/blog/tutorials/intro-to-classes#comment-523</link>
		<dc:creator>Maik</dc:creator>
		<pubDate>Thu, 05 Feb 2009 10:28:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.guru.net.nz/blog/?page_id=224#comment-523</guid>
		<description>Allright i&#039;ll look into that. 

I&#039;m learning to write code manually instead of just copy pasting. While doing so i hope to understand the code i&#039;m writing a little bit better.  

My project:
I&#039;m trying to implement OOP in my own build CMS and eventually have a library/framework for new clients.

*I&#039;m dutch so please excuse my english and the way i __construct :P sentences*</description>
		<content:encoded><![CDATA[<p>Allright i&#8217;ll look into that. </p>
<p>I&#8217;m learning to write code manually instead of just copy pasting. While doing so i hope to understand the code i&#8217;m writing a little bit better.  </p>
<p>My project:<br />
I&#8217;m trying to implement OOP in my own build CMS and eventually have a library/framework for new clients.</p>
<p>*I&#8217;m dutch so please excuse my english and the way i __construct <img src='http://www.guru.net.nz/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  sentences*</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GuruBob</title>
		<link>http://www.guru.net.nz/blog/tutorials/intro-to-classes#comment-522</link>
		<dc:creator>GuruBob</dc:creator>
		<pubDate>Thu, 05 Feb 2009 10:17:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.guru.net.nz/blog/?page_id=224#comment-522</guid>
		<description>The best thing is looking for documented examples and asking for help.  It certainly helps if you know some of the built in constants (like __FUNCTION__) so you can echo where you&#039;re at in the code.  Also if you have access to a PHP debugger (sorry I don&#039;t know any good ones, I have tried many trial versions though) you can also step through the code and watch the variables and objects being created.

Try to find a real world example that you can apply a class to and use it.  If you can make your classes as generic as possible you can reuse them in different projects and increase their power and functionality accordingly.

What kind of projects are you working on?</description>
		<content:encoded><![CDATA[<p>The best thing is looking for documented examples and asking for help.  It certainly helps if you know some of the built in constants (like __FUNCTION__) so you can echo where you&#8217;re at in the code.  Also if you have access to a PHP debugger (sorry I don&#8217;t know any good ones, I have tried many trial versions though) you can also step through the code and watch the variables and objects being created.</p>
<p>Try to find a real world example that you can apply a class to and use it.  If you can make your classes as generic as possible you can reuse them in different projects and increase their power and functionality accordingly.</p>
<p>What kind of projects are you working on?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maik</title>
		<link>http://www.guru.net.nz/blog/tutorials/intro-to-classes#comment-521</link>
		<dc:creator>Maik</dc:creator>
		<pubDate>Thu, 05 Feb 2009 10:12:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.guru.net.nz/blog/?page_id=224#comment-521</guid>
		<description>Thanks alot, i spend all day figuring it out, but since i am just starting OOP in php i couldnt find the error.

Your comments and echo-ing which function you&#039;re calling also really helped.

Do you got any tips for learning OOP ?</description>
		<content:encoded><![CDATA[<p>Thanks alot, i spend all day figuring it out, but since i am just starting OOP in php i couldnt find the error.</p>
<p>Your comments and echo-ing which function you&#8217;re calling also really helped.</p>
<p>Do you got any tips for learning OOP ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GuruBob</title>
		<link>http://www.guru.net.nz/blog/tutorials/intro-to-classes#comment-520</link>
		<dc:creator>GuruBob</dc:creator>
		<pubDate>Thu, 05 Feb 2009 09:55:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.guru.net.nz/blog/?page_id=224#comment-520</guid>
		<description>Oh, and to paste that code in like that:
&lt; pre lang=&quot;php&quot; &gt;
... paste your code in here ...
&lt; /pre &gt;
Note I&#039;ve included extra spaces in the preformat tag so they don&#039;t actually preformat this comment.</description>
		<content:encoded><![CDATA[<p>Oh, and to paste that code in like that:<br />
< pre lang="php" ><br />
&#8230; paste your code in here &#8230;<br />
< /pre ><br />
Note I&#8217;ve included extra spaces in the preformat tag so they don&#8217;t actually preformat this comment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GuruBob</title>
		<link>http://www.guru.net.nz/blog/tutorials/intro-to-classes#comment-519</link>
		<dc:creator>GuruBob</dc:creator>
		<pubDate>Thu, 05 Feb 2009 09:54:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.guru.net.nz/blog/?page_id=224#comment-519</guid>
		<description>There was a couple of bugs, but I&#039;ve just written and tested this in PHP 5.2.8-cli.
&lt;pre lang=&quot;php&quot;&gt;
&lt;?php
	class Vehicle
	{
		function __construct($data=null)
		{
			$this-&gt;tankSize = ($data[&#039;tankSize&#039;]) ? $data[&#039;tankSize&#039;] : 50;	// Default tank size of 50L
			$this-&gt;engineSize = ($data[&#039;engineSize&#039;]) ? $data[&#039;engineSize&#039;] : 1.6;	// Default engine size of 1.6L
			$this-&gt;exteriorColor = ($data[&#039;exteriorColor&#039;]) ? $data[&#039;exteriorColor&#039;] : &#039;unpainted&#039;;	// Default colour of &quot;unpainted&quot;
			$this-&gt;odometer = 0;	// Every new car starts with zero km on the clock

			echo &quot;(&quot;.__FUNCTION__.&quot;) We just made a new &quot;.$this-&gt;exteriorColor.&quot; car that has a &quot;.$this-&gt;tankSize.&quot;L tank and a &quot;.$this-&gt;engineSize.&quot; engine.\n&quot;;
		}

		function __destruct()
		{
			echo &quot;(&quot;.__FUNCTION__.&quot;) This car object is being destroyed and there is &quot;.$this-&gt;fuelRemaining.&quot;L of fuel left.\n&quot;;
			echo &quot;(&quot;.__FUNCTION__.&quot;) It has also traveled &quot;.$this-&gt;odometer.&quot;km.  Not bad for a &quot;.$this-&gt;exteriorColor.&quot; car!\n&quot;;
		}

		function driveDistance($distance,$speed)
		{
			// Rough formula that means going 50km at 80km/hr w/ a 1.6L car uses 6.4L ...
			$fuelRequired = $distance * $speed * $this-&gt;engineSize / 1000;
			// echo &quot;  We are about to drive &quot;.$distance.&quot;km at &quot;.$speed.&quot;km/hr - that requires &quot;.$fuelRequired.&quot;L of fuel\n&quot;;
			if ($fuelRequired &gt; $this-&gt;fuelRemaining)
			{
				echo &quot;(&quot;.__FUNCTION__.&quot;) Not enough fuel to go &quot;.$distance.&quot;km at &quot;.$speed.&quot;km/hr\n&quot;;
				return false;
			}
			$this-&gt;fuelRemaining -= $fuelRequired;
			$this-&gt;odometer += $distance;
			return true;
		}

		function refillTank()
		{
			echo &quot;(&quot;.__FUNCTION__.&quot;) The fuel tank is currently &quot;.ceil(($this-&gt;fuelRemaining/$this-&gt;tankSize)*100).&quot;% full - we will refill it.\n&quot;;
			$this-&gt;fuelRemaining = $this-&gt;tankSize;
			echo &quot;(&quot;.__FUNCTION__.&quot;) The fuel tank is now &quot;.ceil(($this-&gt;fuelRemaining/$this-&gt;tankSize)*100).&quot;% full\n&quot;;
		}
	}

	// ---- Main Program ----

	$car = new Vehicle(array(
		&#039;engineSize&#039;=&gt;1.6,
		&#039;tankSize&#039;=&gt;35,
		&#039;exteriorColor&#039;=&gt;&#039;red&#039;
	));

	$car-&gt;refillTank();

	// Drive this car in 1km chunks until the tank runs dry.
	echo &quot;Let&#039;s drive this car until we run out of fuel!\n&quot;;
	while ($car-&gt;driveDistance(1,50))
		echo &#039;.&#039;;

	echo &quot;\nThe car was able to drive &quot;.$car-&gt;odometer.&quot;km before it could go no further.\n&quot;;	
	
	// End of script - the car object will be destroyed
?&gt;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>There was a couple of bugs, but I&#8217;ve just written and tested this in PHP 5.2.8-cli.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #000000; font-weight: bold;">class</span> Vehicle
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tankSize</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tankSize'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tankSize'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #cc66cc;">50</span><span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// Default tank size of 50L</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">engineSize</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'engineSize'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'engineSize'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color:#800080;">1.6</span><span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// Default engine size of 1.6L</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">exteriorColor</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'exteriorColor'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'exteriorColor'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'unpainted'</span><span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// Default colour of &quot;unpainted&quot;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">odometer</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>	<span style="color: #666666; font-style: italic;">// Every new car starts with zero km on the clock</span>
&nbsp;
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;(&quot;</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">__FUNCTION__</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;) We just made a new &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">exteriorColor</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; car that has a &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tankSize</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;L tank and a &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">engineSize</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; engine.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">function</span> __destruct<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;(&quot;</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">__FUNCTION__</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;) This car object is being destroyed and there is &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fuelRemaining</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;L of fuel left.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;(&quot;</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">__FUNCTION__</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;) It has also traveled &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">odometer</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;km.  Not bad for a &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">exteriorColor</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; car!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">function</span> driveDistance<span style="color: #009900;">&#40;</span><span style="color: #000088;">$distance</span><span style="color: #339933;">,</span><span style="color: #000088;">$speed</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// Rough formula that means going 50km at 80km/hr w/ a 1.6L car uses 6.4L ...</span>
			<span style="color: #000088;">$fuelRequired</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$distance</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$speed</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">engineSize</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">1000</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// echo &quot;  We are about to drive &quot;.$distance.&quot;km at &quot;.$speed.&quot;km/hr - that requires &quot;.$fuelRequired.&quot;L of fuel\n&quot;;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$fuelRequired</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fuelRemaining</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;(&quot;</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">__FUNCTION__</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;) Not enough fuel to go &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$distance</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;km at &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$speed</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;km/hr<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fuelRemaining</span> <span style="color: #339933;">-=</span> <span style="color: #000088;">$fuelRequired</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">odometer</span> <span style="color: #339933;">+=</span> <span style="color: #000088;">$distance</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">function</span> refillTank<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;(&quot;</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">__FUNCTION__</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;) The fuel tank is currently &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">ceil</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fuelRemaining</span><span style="color: #339933;">/</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tankSize</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">% f</span>ull - we will refill it.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fuelRemaining</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tankSize</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;(&quot;</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">__FUNCTION__</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;) The fuel tank is now &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">ceil</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fuelRemaining</span><span style="color: #339933;">/</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tankSize</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">% f</span>ull<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// ---- Main Program ----</span>
&nbsp;
	<span style="color: #000088;">$car</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Vehicle<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'engineSize'</span><span style="color: #339933;">=&gt;</span><span style="color:#800080;">1.6</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'tankSize'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">35</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'exteriorColor'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'red'</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">refillTank</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Drive this car in 1km chunks until the tank runs dry.</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Let's drive this car until we run out of fuel!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">driveDistance</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'.'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>The car was able to drive &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$car</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">odometer</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;km before it could go no further.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>	
&nbsp;
	<span style="color: #666666; font-style: italic;">// End of script - the car object will be destroyed</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: GuruBob</title>
		<link>http://www.guru.net.nz/blog/tutorials/intro-to-classes#comment-518</link>
		<dc:creator>GuruBob</dc:creator>
		<pubDate>Thu, 05 Feb 2009 07:46:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.guru.net.nz/blog/?page_id=224#comment-518</guid>
		<description>Yes, I can ... stand by.</description>
		<content:encoded><![CDATA[<p>Yes, I can &#8230; stand by.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maik</title>
		<link>http://www.guru.net.nz/blog/tutorials/intro-to-classes#comment-517</link>
		<dc:creator>Maik</dc:creator>
		<pubDate>Thu, 05 Feb 2009 06:53:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.guru.net.nz/blog/?page_id=224#comment-517</guid>
		<description>Could you help me please ?</description>
		<content:encoded><![CDATA[<p>Could you help me please ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maik</title>
		<link>http://www.guru.net.nz/blog/tutorials/intro-to-classes#comment-516</link>
		<dc:creator>Maik</dc:creator>
		<pubDate>Tue, 03 Feb 2009 11:52:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.guru.net.nz/blog/?page_id=224#comment-516</guid>
		<description>dont know answer ?</description>
		<content:encoded><![CDATA[<p>dont know answer ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maik</title>
		<link>http://www.guru.net.nz/blog/tutorials/intro-to-classes#comment-515</link>
		<dc:creator>Maik</dc:creator>
		<pubDate>Tue, 03 Feb 2009 10:23:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.guru.net.nz/blog/?page_id=224#comment-515</guid>
		<description>motorInhoud / 1000 / 1000 ;
	if ($benzineNodig benzineResterend)
	{
		$this -&gt; error =&#039;Niet genoeg benzine om &#039;.$afstand.&#039; km af te leggen met &#039;.$snelheid.&#039; km per uur&#039;;
		return false;
	}
		
	
	$this-&gt;benzineResterend -= $benzineNodig;
	$this-&gt;meter += $afstand;
	return true;	
}

function tanken()
{
	$this-&gt;benzineResterend = $this-&gt;tankInhoud;
}

function __destruct()
  {
    echo &quot;Deze auto word vernietigd en heeft nog &quot;.$this-&gt;benzineResterend.&quot;L benzine over.\n&quot;;
    echo &quot;Deze auto heeft ook &quot;.$this-&gt;meter.&quot;km afgelegd.  Niet slecht voor een &quot;.$this-&gt;kleur.&quot; auto!\n&quot;;
  }

function __construct($data=null)
{
	if ($data[&#039;tankInhoud&#039;]) $this-&gt;tankInhoud = $data[&#039;tankInhoud&#039;];
	if($data[&#039;motorInhoud&#039;]) $this-&gt;motorInhoud = $data[&#039;motorInhoud&#039;];
}

}

$autotje = new auto(array(
    &#039;motorInhoud&#039;=&gt;1.6,
    &#039;tankInhoud&#039;=&gt;70
  ));
   
   $autotje -&gt; tanken();
	
	
while ($autotje-&gt;rijdAfstand(1,50))
	echo &#039;. &#039;;
	
echo &quot;\n De auto is &quot;. $autotje-&gt;meter .&quot; km ver gekomen \n&quot;;


?&gt;</description>
		<content:encoded><![CDATA[<p>motorInhoud / 1000 / 1000 ;<br />
	if ($benzineNodig benzineResterend)<br />
	{<br />
		$this -&gt; error =&#8217;Niet genoeg benzine om &#8216;.$afstand.&#8217; km af te leggen met &#8216;.$snelheid.&#8217; km per uur&#8217;;<br />
		return false;<br />
	}</p>
<p>	$this-&gt;benzineResterend -= $benzineNodig;<br />
	$this-&gt;meter += $afstand;<br />
	return true;<br />
}</p>
<p>function tanken()<br />
{<br />
	$this-&gt;benzineResterend = $this-&gt;tankInhoud;<br />
}</p>
<p>function __destruct()<br />
  {<br />
    echo &#8220;Deze auto word vernietigd en heeft nog &#8220;.$this-&gt;benzineResterend.&#8221;L benzine over.\n&#8221;;<br />
    echo &#8220;Deze auto heeft ook &#8220;.$this-&gt;meter.&#8221;km afgelegd.  Niet slecht voor een &#8220;.$this-&gt;kleur.&#8221; auto!\n&#8221;;<br />
  }</p>
<p>function __construct($data=null)<br />
{<br />
	if ($data['tankInhoud']) $this-&gt;tankInhoud = $data['tankInhoud'];<br />
	if($data['motorInhoud']) $this-&gt;motorInhoud = $data['motorInhoud'];<br />
}</p>
<p>}</p>
<p>$autotje = new auto(array(<br />
    &#8216;motorInhoud&#8217;=&gt;1.6,<br />
    &#8216;tankInhoud&#8217;=&gt;70<br />
  ));</p>
<p>   $autotje -&gt; tanken();</p>
<p>while ($autotje-&gt;rijdAfstand(1,50))<br />
	echo &#8216;. &#8216;;</p>
<p>echo &#8220;\n De auto is &#8220;. $autotje-&gt;meter .&#8221; km ver gekomen \n&#8221;;</p>
<p>?&gt;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

