<?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>Steven R. Wamsley &#187; Programming</title>
	<atom:link href="http://ne0phyte.com/blog/category/home-page/computer-technology/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://ne0phyte.com</link>
	<description>Musician, developer, and software architect... aka ne0phyte</description>
	<lastBuildDate>Thu, 11 Aug 2011 14:23:29 +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>PHP Quiz: Passing Objects By Value vs. Reference</title>
		<link>http://ne0phyte.com/blog/2010/04/06/php-quiz-passing-objects-by-value-vs-reference/</link>
		<comments>http://ne0phyte.com/blog/2010/04/06/php-quiz-passing-objects-by-value-vs-reference/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 23:50:36 +0000</pubDate>
		<dc:creator>ne0phyte</dc:creator>
				<category><![CDATA[Computer Technology]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://ne0phyte.com/?p=176</guid>
		<description><![CDATA[Here is something to test your knowledge of how PHP handles passing objects by value vs. reference. Try to figure this out without using a PHP interpreter. What is the output of the following code: class Foo { private $bar; public function Foo($x) { $this-&#62;bar = $x; } public function getBar() { return $this-&#62;bar; } [...]]]></description>
			<content:encoded><![CDATA[<p>Here is something to test your knowledge of how PHP handles passing objects by value vs. reference. Try to figure this out without using a PHP interpreter.</p>
<p>What is the output of the following code:</p>
<pre>class Foo {
  private $bar;
  public function Foo($x) {
    $this-&gt;bar = $x;
  }
  public function getBar() {
    return $this-&gt;bar;
  }
  public function setBar($x) {
    $this-&gt;bar = $x;
  }
}

function changeFooByValue($foo) {
 $foo-&gt;setBar('high');
 $foo = new Foo('too low');
}

function changeFooByRef(&amp;$foo) {
  $foo-&gt;setBar('just high enough');
  $foo = new Foo('too high');
}

$foo = new Foo('low');
echo "Bar: " . $foo-&gt;getBar() . "\n";

changeFooByValue($foo);
echo "Bar: " . $foo-&gt;getBar() . "\n";

changeFooByRef($foo);
echo "Bar: " . $foo-&gt;getBar() . "\n";
</pre>
<p>Is it:</p>
<p>A:</p>
<pre>Bar: low
Bar: too low
Bar: too high</pre>
<p>B:</p>
<pre>Bar: low
Bar: too low
Bar: too high</pre>
<p>C:</p>
<pre>Bar: low
Bar: too low
Bar: too high</pre>
<p>D:</p>
<p>Parse/syntax error</p>
<p>E:</p>
<p>None of the above</p>
]]></content:encoded>
			<wfw:commentRss>http://ne0phyte.com/blog/2010/04/06/php-quiz-passing-objects-by-value-vs-reference/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

