<?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: PHP &amp; Ampersand: Passing by Reference</title>
	<atom:link href="http://www.phpreferencebook.com/samples/php-pass-by-reference/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpreferencebook.com/samples/php-pass-by-reference/</link>
	<description>PHP Reference: Beginner to Intermediate PHP5</description>
	<lastBuildDate>Wed, 07 Sep 2011 23:05:47 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: Miha</title>
		<link>http://www.phpreferencebook.com/samples/php-pass-by-reference/comment-page-1/#comment-1285</link>
		<dc:creator>Miha</dc:creator>
		<pubDate>Sat, 09 Jan 2010 16:40:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=165#comment-1285</guid>
		<description>Brandon is right! As of PHP 5.3.0, you will get a warning saying that &quot;call-time pass-by-reference&quot; is deprecated when you use &amp; in $foo-&gt;setBar(&quot;xxx&quot;).

Besides objects are passed by reference by default. 

Read here:http://www.webeks.net/programming/php/ampersand-operator-used-for-assigning-reference.html</description>
		<content:encoded><![CDATA[<p>Brandon is right! As of PHP 5.3.0, you will get a warning saying that &#8220;call-time pass-by-reference&#8221; is deprecated when you use &#038; in $foo->setBar(&#8220;xxx&#8221;).</p>
<p>Besides objects are passed by reference by default. </p>
<p>Read here:<a href="http://www.webeks.net/programming/php/ampersand-operator-used-for-assigning-reference.html" rel="nofollow">http://www.webeks.net/programming/php/ampersand-operator-used-for-assigning-reference.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon</title>
		<link>http://www.phpreferencebook.com/samples/php-pass-by-reference/comment-page-1/#comment-1101</link>
		<dc:creator>Brandon</dc:creator>
		<pubDate>Thu, 03 Dec 2009 14:48:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=165#comment-1101</guid>
		<description>As Scott said, passing a reference in from the call will work, but it has been deprecated, so the following form is preferred:
&lt;pre lang=&quot;php&quot;&gt;
function add(&amp;$var){ // The &amp; is before the argument $var
$var++;
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>As Scott said, passing a reference in from the call will work, but it has been deprecated, so the following form is preferred:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> add<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// The &amp; is before the argument $var</span>
<span style="color: #000088;">$var</span><span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://www.phpreferencebook.com/samples/php-pass-by-reference/comment-page-1/#comment-826</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Sat, 05 Sep 2009 21:13:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=165#comment-826</guid>
		<description>In addition to prepending a function parameter with an ampersand, the ampersand may also be prepended to the variable in the calling statement, and the same effect will be achieved.

Not sure if this is a language quirk, or it was intended that way, but it works!

ex:
&lt;pre lang=&quot;php&quot;&gt;
   var1 = 0;
   var2 = 100;

   // changes var 1 to 5!   
   callMe(&amp;var1, var2);

   function callMe(param1, param2) {
      param1 = 5;
   }
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>In addition to prepending a function parameter with an ampersand, the ampersand may also be prepended to the variable in the calling statement, and the same effect will be achieved.</p>
<p>Not sure if this is a language quirk, or it was intended that way, but it works!</p>
<p>ex:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">   var1 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
   var2 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// changes var 1 to 5!   </span>
   callMe<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>var1<span style="color: #339933;">,</span> var2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">function</span> callMe<span style="color: #009900;">&#40;</span>param1<span style="color: #339933;">,</span> param2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      param1 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
	</item>
</channel>
</rss>

