<?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>Wojciech Jamrozy blog &#187; PHP</title>
	<atom:link href="http://www.wojtekrj.net/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wojtekrj.net</link>
	<description>Blog about computer science, programming and linux</description>
	<lastBuildDate>Sun, 23 Oct 2011 21:57:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>[PHP] Variable with name of other variable &#8211; &#8220;variable variables&#8221;</title>
		<link>http://www.wojtekrj.net/2008/09/php-variable-with-name-of-other-variable-variable-variables/</link>
		<comments>http://www.wojtekrj.net/2008/09/php-variable-with-name-of-other-variable-variable-variables/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 16:50:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[variable]]></category>

		<guid isPermaLink="false">http://www.wojtekrj.net/?p=114</guid>
		<description><![CDATA[When you write in PHP $$name, parser treats it as variable, wchich name is value of $name &#8211; it works like pointer: &#60;? $var1 = 'test1'; $var2 = 'test2'; $a = 'var1'; echo $$a.'&#60;br&#62;'; $a = 'var2'; echo $$a; ?&#62; output: test1 test2]]></description>
			<content:encoded><![CDATA[<p>When you write in PHP <em>$$name</em>, parser treats it as variable, wchich name is value of <em>$name</em> &#8211; it works like pointer:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> 
<span style="color: #000088;">$var1</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'test1'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$var2</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'test2'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'var1'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$$a</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;br&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'var2'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$$a</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>output:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">test1
test2</pre></div></div>

<p><a class="a2a_button_wykop" href="http://www.addtoany.com/add_to/wykop?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-variable-with-name-of-other-variable-variable-variables%2F&amp;linkname=%5BPHP%5D%20Variable%20with%20name%20of%20other%20variable%20%26%238211%3B%20%26%238220%3Bvariable%20variables%26%238221%3B" title="Wykop" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/wykop.png" width="16" height="16" alt="Wykop"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-variable-with-name-of-other-variable-variable-variables%2F&amp;linkname=%5BPHP%5D%20Variable%20with%20name%20of%20other%20variable%20%26%238211%3B%20%26%238220%3Bvariable%20variables%26%238221%3B" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-variable-with-name-of-other-variable-variable-variables%2F&amp;linkname=%5BPHP%5D%20Variable%20with%20name%20of%20other%20variable%20%26%238211%3B%20%26%238220%3Bvariable%20variables%26%238221%3B" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-variable-with-name-of-other-variable-variable-variables%2F&amp;linkname=%5BPHP%5D%20Variable%20with%20name%20of%20other%20variable%20%26%238211%3B%20%26%238220%3Bvariable%20variables%26%238221%3B" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-variable-with-name-of-other-variable-variable-variables%2F&amp;linkname=%5BPHP%5D%20Variable%20with%20name%20of%20other%20variable%20%26%238211%3B%20%26%238220%3Bvariable%20variables%26%238221%3B" title="Digg" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-variable-with-name-of-other-variable-variable-variables%2F&amp;linkname=%5BPHP%5D%20Variable%20with%20name%20of%20other%20variable%20%26%238211%3B%20%26%238220%3Bvariable%20variables%26%238221%3B" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_msdn" href="http://www.addtoany.com/add_to/msdn?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-variable-with-name-of-other-variable-variable-variables%2F&amp;linkname=%5BPHP%5D%20Variable%20with%20name%20of%20other%20variable%20%26%238211%3B%20%26%238220%3Bvariable%20variables%26%238221%3B" title="MSDN" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/msdn.png" width="16" height="16" alt="MSDN"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-variable-with-name-of-other-variable-variable-variables%2F&amp;linkname=%5BPHP%5D%20Variable%20with%20name%20of%20other%20variable%20%26%238211%3B%20%26%238220%3Bvariable%20variables%26%238221%3B" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_technotizie" href="http://www.addtoany.com/add_to/technotizie?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-variable-with-name-of-other-variable-variable-variables%2F&amp;linkname=%5BPHP%5D%20Variable%20with%20name%20of%20other%20variable%20%26%238211%3B%20%26%238220%3Bvariable%20variables%26%238221%3B" title="Technotizie" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technotizie.png" width="16" height="16" alt="Technotizie"/></a><a class="a2a_button_technet" href="http://www.addtoany.com/add_to/technet?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-variable-with-name-of-other-variable-variable-variables%2F&amp;linkname=%5BPHP%5D%20Variable%20with%20name%20of%20other%20variable%20%26%238211%3B%20%26%238220%3Bvariable%20variables%26%238221%3B" title="TechNet" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technet.png" width="16" height="16" alt="TechNet"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-variable-with-name-of-other-variable-variable-variables%2F&amp;title=%5BPHP%5D%20Variable%20with%20name%20of%20other%20variable%20%26%238211%3B%20%26%238220%3Bvariable%20variables%26%238221%3B" id="wpa2a_2">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wojtekrj.net/2008/09/php-variable-with-name-of-other-variable-variable-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[PHP] Execution/evaluation of code from variable</title>
		<link>http://www.wojtekrj.net/2008/09/php-execution-evalutaion-of-code-from-variable/</link>
		<comments>http://www.wojtekrj.net/2008/09/php-execution-evalutaion-of-code-from-variable/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 13:26:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.wojtekrj.net/?p=111</guid>
		<description><![CDATA[In PHP we can use function eval in order to evaluate given variable (string) as PHP code: &#60;? $var = 'for ($i=0;$i&#60;5;$i++) { echo $i.\'&#60;br&#62;\'; }'; eval&#40;$var&#41;; ?&#62; output: 0 1 2 3 4]]></description>
			<content:encoded><![CDATA[<p>In PHP we can use function <em>eval </em>in order to evaluate given variable (string) as PHP code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> 
<span style="color: #000088;">$var</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'for ($i=0;$i&lt;5;$i++)
{
	echo $i.\'&lt;br&gt;\';
}'</span><span style="color: #339933;">;</span>
<span style="color: #990000;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>output:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">0</span>
<span style="color: #000000;">1</span>
<span style="color: #000000;">2</span>
<span style="color: #000000;">3</span>
<span style="color: #000000;">4</span></pre></div></div>

<p><a class="a2a_button_wykop" href="http://www.addtoany.com/add_to/wykop?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-execution-evalutaion-of-code-from-variable%2F&amp;linkname=%5BPHP%5D%20Execution%2Fevaluation%20of%20code%20from%20variable" title="Wykop" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/wykop.png" width="16" height="16" alt="Wykop"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-execution-evalutaion-of-code-from-variable%2F&amp;linkname=%5BPHP%5D%20Execution%2Fevaluation%20of%20code%20from%20variable" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-execution-evalutaion-of-code-from-variable%2F&amp;linkname=%5BPHP%5D%20Execution%2Fevaluation%20of%20code%20from%20variable" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-execution-evalutaion-of-code-from-variable%2F&amp;linkname=%5BPHP%5D%20Execution%2Fevaluation%20of%20code%20from%20variable" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-execution-evalutaion-of-code-from-variable%2F&amp;linkname=%5BPHP%5D%20Execution%2Fevaluation%20of%20code%20from%20variable" title="Digg" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-execution-evalutaion-of-code-from-variable%2F&amp;linkname=%5BPHP%5D%20Execution%2Fevaluation%20of%20code%20from%20variable" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_button_msdn" href="http://www.addtoany.com/add_to/msdn?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-execution-evalutaion-of-code-from-variable%2F&amp;linkname=%5BPHP%5D%20Execution%2Fevaluation%20of%20code%20from%20variable" title="MSDN" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/msdn.png" width="16" height="16" alt="MSDN"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-execution-evalutaion-of-code-from-variable%2F&amp;linkname=%5BPHP%5D%20Execution%2Fevaluation%20of%20code%20from%20variable" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_technotizie" href="http://www.addtoany.com/add_to/technotizie?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-execution-evalutaion-of-code-from-variable%2F&amp;linkname=%5BPHP%5D%20Execution%2Fevaluation%20of%20code%20from%20variable" title="Technotizie" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technotizie.png" width="16" height="16" alt="Technotizie"/></a><a class="a2a_button_technet" href="http://www.addtoany.com/add_to/technet?linkurl=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-execution-evalutaion-of-code-from-variable%2F&amp;linkname=%5BPHP%5D%20Execution%2Fevaluation%20of%20code%20from%20variable" title="TechNet" rel="nofollow" target="_blank"><img src="http://www.wojtekrj.net/wp-content/plugins/add-to-any/icons/technet.png" width="16" height="16" alt="TechNet"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.wojtekrj.net%2F2008%2F09%2Fphp-execution-evalutaion-of-code-from-variable%2F&amp;title=%5BPHP%5D%20Execution%2Fevaluation%20of%20code%20from%20variable" id="wpa2a_4">Share/Save</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wojtekrj.net/2008/09/php-execution-evalutaion-of-code-from-variable/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

