<?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>Skypher &#187; php</title>
	<atom:link href="http://skypher.com/index.php/category/languages/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://skypher.com</link>
	<description>The blog for absolutely nothing!</description>
	<lastBuildDate>Fri, 16 Jul 2010 08:26:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>PHP Strings &#8216; vs &#8220;</title>
		<link>http://skypher.com/index.php/2010/05/17/php-strings-vs/</link>
		<comments>http://skypher.com/index.php/2010/05/17/php-strings-vs/#comments</comments>
		<pubDate>Mon, 17 May 2010 19:45:22 +0000</pubDate>
		<dc:creator>Cipher</dc:creator>
				<category><![CDATA[Programming Languages]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=464</guid>
		<description><![CDATA[<p>It&#8217;s wideley known that PHP supports both &#8216; (single quote) and &#8221; (double qoute) for string delimiting.
It&#8217;s also widely known that PHP evaluates the DQ (Double Quote) Strings and replaces variables with their actual value...]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s wideley known that PHP supports both &#8216; (single quote) and &#8221; (double qoute) for string delimiting.<br />
It&#8217;s also widely known that PHP evaluates the DQ (Double Quote) Strings and replaces variables with their actual value. But not a lot has been written about what is actually faster.</p>
<p>Its quite simple: SQ (Single Quotes) is faster. Hands down.</p>
<p>It&#8217;s even faster when adding the variable by concatenating multiple strings. Please look at the following code: <code><br />
//variable used in DQ<br />
$time = microtime();<br />
for($i=0;$i<1000;++$i){<br />
	$$i = "Some Random String $i with a number";<br />
}<br />
echo microtime()-$time;<br />
//Variable used in concatenation with DQ<br />
echo '<br/>';<br />
for($i=0;$i<1000;++$i){<br />
	$$i = "Some Random String ".$i." with a number";<br />
}<br />
echo microtime()-$time;<br />
//variable used in concatenation with SQ<br />
echo '<br/>';<br />
$time = microtime();<br />
for($i=0;$i<1000;++$i){<br />
	$$i = 'Some Random String '.$i.' with a number';<br />
}<br />
echo microtime()-$time;<br />
</code></p>
<p>Code speaks for itself. In order of speed:<br />
1. SQ<br />
2. DQ without concat.<br />
3. DQ with concat.</p>
<p>Why, easy: Single quotes does not require evaluating. DQ without concat requires 1 evaluate. DQ with concat requires 2 evaluations of the string.<br />
So, in conclusion: double quotes are evil!</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2010/05/17/php-strings-vs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>String concatenation vs. Array joins</title>
		<link>http://skypher.com/index.php/2008/09/30/string-concatenation-vs-array-joins/</link>
		<comments>http://skypher.com/index.php/2008/09/30/string-concatenation-vs-array-joins/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 19:05:22 +0000</pubDate>
		<dc:creator>Cipher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[array join]]></category>
		<category><![CDATA[benchmark]]></category>
		<category><![CDATA[string concatenation]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=54</guid>
		<description><![CDATA[I've read several websites which claim that string concatenation is outperformed by array joining in PHP. I know from firsthand that this certainly is a fact in ASP. And it's considered a 'best practice' in Javascript and probably several other languages. But PHP has always been a bit different on some parts, so I decided to test this and came to some interesting conclusions.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve read several websites which claim that string concatenation is outperformed by array joining in PHP. I know from firsthand that this certainly is a fact in ASP. And it&#8217;s considered a &#8216;best practice&#8217; in Javascript and probably several other languages. But PHP has always been a bit different on some parts, so I decided to test this and came to some interesting conclusions.</p>
<p>The following tests were performed 50 times with PHP 5.2.6.</p>
<p>First I tested the following pieces of code for parse time, $iConcats was set to 5000:</p>
<p style="background-color: #dadada; font-family: Courier;">for($i=0; $i&lt;$iConcats; ++$i)<br />
{<br />
$o .= &#8216;aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&#8217;;<br />
}</p>
<p>This parsed on avarage in <strong>0.0065</strong> seconds.<br />
Next up was the array equivalent:</p>
<p style="background-color: #dadada; font-family: Courier;">for($i=0; $i&lt;$iConcats; ++$i)<br />
{<br />
$a[] = &#8216;aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&#8217;;<br />
}<br />
$a = join(&#8221;, $a);</p>
<p>This parsed on average in about <strong>0.0187</strong> seconds. That&#8217;s almost 3 times slower!<br />
I deliberately added the join statement as it completes the comparison. And dor the more visually oriented amongst us, google provides nice graphs:</p>
<p style="text-align: center;">
<img class="aligncenter" src="http://chart.apis.google.com/chart?chs=500x200&amp;chd=t:0.00470614433289,0.00564002990723,0.00468802452087,0.0044960975647,0.00556802749634,0.00672197341919,0.00454592704773,0.0051600933075,0.00535488128662,0.00454187393188,0.00635504722595,0.00609087944031,0.00536584854126,0.00536298751831,0.00517606735229,0.00724506378174,0.00739192962646,0.00564193725586,0.00616383552551,0.00612497329712,0.00667095184326,0.00691294670105,0.00757193565369,0.00617218017578,0.00629806518555,0.00727605819702,0.00642204284668,0.00821805000305,0.00648093223572,0.00948882102966,0.00612497329712,0.00698709487915,0.00582408905029,0.00612592697144,0.0068621635437,0.00661897659302,0.00851392745972,0.0065929889679,0.00689792633057,0.00656199455261,0.00774216651917,0.0059220790863,0.005854845047,0.00877094268799,0.00671696662903,0.00802493095398,0.00566697120667,0.00665879249573,0.00682306289673,0.00703406333923,0.00642085075378|0.0150489807129,0.0178120136261,0.013365983963,0.0120301246643,0.0124061107635,0.0122818946838,0.0108051300049,0.0140759944916,0.0118789672852,0.0134541988373,0.0175681114197,0.0260560512543,0.0253939628601,0.0266220569611,0.0711159706116,0.0152308940887,0.0150091648102,0.0224511623383,0.0174009799957,0.073380947113,0.0262751579285,0.0150461196899,0.0156948566437,0.0278759002686,0.0239629745483,0.0178570747375,0.0188171863556,0.0134708881378,0.0161991119385,0.0270309448242,0.0226180553436,0.0188419818878,0.0169649124146,0.016037940979,0.011234998703,0.012237071991,0.0118451118469,0.0125539302826,0.0106329917908,0.0123829841614,0.0126929283142,0.012542963028,0.0130019187927,0.0125479698181,0.0149660110474,0.0128901004791,0.0132501125336,0.0116021633148,0.0139989852905,0.0148987770081,0.0136260986328&amp;cht=lc&amp;chds=0,0.00948882102966,0,0.073380947113&amp;chco=CFE17E,90B821" alt="" /></p>
<p style="text-align: center;"><img class="aligncenter" src="http://chart.apis.google.com/chart?chs=250x100&amp;chd=t:0.00653198719025,0.0187397384644&amp;cht=p3&amp;chl=Test%201|Test%202&amp;chco=90B821,CFE17E" alt="Who doesn't like pie?" /></p>
<p>During the measurements I also tracked the memory usage, which had the same outcome, concatenation wins again.</p>
<p>For string concatenation memory usage was ~56Mb. The array version used up ~155Mb. Again the three times! And again, let&#8217;s look at some graphs:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://chart.apis.google.com/chart?chs=500x200&amp;chd=t:-1,48,48,48,48,48,48,48,48,48,48,48,224,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,312,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48|-1,536,144,144,144,144,144,144,144,216,144,144,144,144,144,144,144,280,176,64,144,152,144,144,144,144,144,144,144,144,144,144,144,136,144,152,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144&amp;cht=lc&amp;chds=0,312,0,536&amp;chco=90B821,CFE17E" alt="" width="500" height="200" /></p>
<p>And in pie:</p>
<p style="text-align: center;"><img class="aligncenter" title="More pie!" src="http://chart.apis.google.com/chart?chs=250x100&amp;chd=t:56.78,155.18&amp;cht=p3&amp;chl=Test%201|Test%202&amp;chco=90B821,CFE17E" alt="" width="250" height="100" /></p>
<p>So in conclusion (at least for PHP 5.2.6) string concatenation is faster than array joins!</p>
<p>Strings vs Arrays: 2-0.</p>
<p>If you have some test resutls you want to share, please respond below or send me an email, you can reach me at: korneelwever. I&#8217;m with the Google mail service <img src='http://skypher.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2008/09/30/string-concatenation-vs-array-joins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Function list for PHP</title>
		<link>http://skypher.com/index.php/2008/07/28/function-list-for-php/</link>
		<comments>http://skypher.com/index.php/2008/07/28/function-list-for-php/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 10:18:36 +0000</pubDate>
		<dc:creator>Cipher</dc:creator>
				<category><![CDATA[notepad++]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[function list]]></category>
		<category><![CDATA[n++]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=28</guid>
		<description><![CDATA[<p>Jens Lorenz&#8217; function list plugin is a very handy tool!</p>
<p>After installation, there are a few things you need to customize...]]></description>
			<content:encoded><![CDATA[<p>Jens Lorenz&#8217; function list plugin is a very handy tool!</p>
<p>After installation, there are a few things you need to customize. For php this is what I did:</p>
<ol>
<li>Open a php file with some functions</li>
<li>Go to Plugins-&gt;Function List-&gt;Language Parsing Rules</li>
<li>Click PHP and the &#8216;add group&#8217; button</li>
<li>Under group rules add the following (without the quotes):
<ol>
<li>function start: &#8220;[\t]*function &#8220;</li>
<li>function name: &#8220;[\w]*&#8221;</li>
<li>function end: &#8220;\(&#8220;</li>
</ol>
</li>
<li> and click &#8216;Try&#8217; and view your list being created.</li>
<li>If you like what you see, click ok if not, you can fiddle with the regex.</li>
</ol>
<p>Keep in mind that this might be different with your code convention, in that case, you&#8217;ll have to adjust the second (function name) regex.</p>
<p>At my current job we don&#8217;t have that much objects and classes, so I&#8217;ll see if i can whiff up a class based regex later.</p>
<p><strong>[edit]</strong><br />
More posts about Notepad++ can be found here: <a title="Notepad++ tag on Skypher.com" href="http://skypher.com/index.php/tag/notepad/">Notepad++  customization</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2008/07/28/function-list-for-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Notepad++ 5.0</title>
		<link>http://skypher.com/index.php/2008/07/11/notepad-50/</link>
		<comments>http://skypher.com/index.php/2008/07/11/notepad-50/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 13:16:08 +0000</pubDate>
		<dc:creator>Cipher</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[completion]]></category>
		<category><![CDATA[ctrl+enter]]></category>
		<category><![CDATA[notepad++]]></category>
		<category><![CDATA[quicktext]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=25</guid>
		<description><![CDATA[<p>Notepad++ released 5.0 some time ago, and recently a rebuffed version. It&#8217;s looking good!</p>
<p>I have some small adjustments for myself and maybe for you.</p>
<p>[ctrl]+[enter] now opens the function suggest by default which was the QuickText Replacer...]]></description>
			<content:encoded><![CDATA[<p>Notepad++ released 5.0 some time ago, and recently a rebuffed version. It&#8217;s looking good!</p>
<p>I have some small adjustments for myself and maybe for you.</p>
<p>[ctrl]+[enter] now opens the function suggest by default which was the QuickText Replacer. Look in the shortcutmapper for this one (#36), just clear it and you&#8217;re back to normal.</p>
<p>The new function hinting system is great. I wish there was a way to add () when inserting a function name, and move the cursor in the brackets. Additionally, some comment on the function&#8217;s use would be helpful on hovering.</p>
<p>I noticed some people were coming to my site to find out how to change the font size, well, this is easy, just hit [ctrl] and scroll your mouse!</p>
<p>For entering some Quicktext please see my <a href="http://skypher.com/wiki/index.php?title=Quicktext.ini">Quicktext Wiki</a>.</p>
<p><strong>[edit]<br />
</strong>Don&#8217;t forget to install the Quicktext plugin which you can find <a title="Quicktext plugin by alphpt." href="http://sourceforge.net/project/downloading.php?group_id=183263&amp;use_mirror=heanet&amp;filename=QuickText-0.2-win32dll.rar&amp;90736719" target="_blank">here</a>.</p>
<p>More posts about Notepad++ can be found here: <a title="Notepad++ tag on Skypher.com" href="http://skypher.com/index.php/tag/notepad/">Notepad++  customization</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2008/07/11/notepad-50/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mandelbrot in PHP</title>
		<link>http://skypher.com/index.php/2008/05/26/mandelbrot-in-php/</link>
		<comments>http://skypher.com/index.php/2008/05/26/mandelbrot-in-php/#comments</comments>
		<pubDate>Mon, 26 May 2008 21:48:42 +0000</pubDate>
		<dc:creator>Cipher</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[fractal]]></category>
		<category><![CDATA[mandelbrot]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=12</guid>
		<description><![CDATA[<p>After reading up on SkyLined&#8217;s post I thought it might be nice to try some in PHP...]]></description>
			<content:encoded><![CDATA[<p>After reading up on SkyLined&#8217;s post I thought it might be nice to try some in PHP. I first Googled for an example and quickly found this post:<a title="Cow's Page on PHP Mandelbrot" href="http://cow.neondragon.net/index.php/2680-Php-Fractal-Generator"></p>
<p>http://cow.neondragon.net/index.php/2680-Php-Fractal-Generator</a></p>
<p>Unfortunately that is quite inefficient. So I made some adjustments. I can now render a 500*500 pixel fractal in 15-16 seconds on my laptop (1.2Ghz DualCore, one used) (<a title="PHP rendered Mandelbrot" href="http://skypher.com/Cipher/fractal.png">see image</a>). That is quite faster than the example.<br />
(I&#8217;ll test on this server and at work for reference, watch for updates). I&#8217;ll post the code here soon.</p>
<p>Next up is a mashup between SkyLined&#8217;s and my script to have PHP render the ASCII art fractals and animations, maybe I can render animated gifs <img src='http://skypher.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2008/05/26/mandelbrot-in-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Notepad++ &amp; PHP</title>
		<link>http://skypher.com/index.php/2008/04/16/notepad-php/</link>
		<comments>http://skypher.com/index.php/2008/04/16/notepad-php/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 17:23:18 +0000</pubDate>
		<dc:creator>Cipher</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[notepad++]]></category>
		<category><![CDATA[suggestion]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=4</guid>
		<description><![CDATA[<p>For my coding I use Notepad++. I really like the personal settings and features of this editor. However, it somewhat lacks in code support...]]></description>
			<content:encoded><![CDATA[<p>For my coding I use Notepad++. I really like the personal settings and features of this editor. However, it somewhat lacks in code support. Having worked with Zend Studio, Dreamweaver, Eclipse and the likes, I found that code suggestion is a really nice feature.</p>
<p>For functions you don&#8217;t use all the time, you might forget what the parameters are, or in which sequence they are to be given. At least I do. The editors mentioned above have a feature where it can suggest a function on the go. So does Notepad++. But (afaik) Zend and Dreamweaver also suggest the parameters. Which N++ does not.</p>
<p>The &#8216;api&#8217; for N++ lacks the parameter suggestion. But I wrote a little script which added the parameters to the file.</p>
<p>You can download a copy of php.api <a title="php.api" href="http://www.skypher.com/Cipher/php.api" target="_blank">here</a>.(use &#8216;save target as&#8217;)</p>
<p>Please note that using the suggestion will result in the description text of the parameters to be added as well. So for now, just use the suggestions as guidance.</p>
<p>To use this file i suggest to set the following settings:<br />
auto-completion enabled on function, starting from 2 charatures (or it will drive you insane with spaces and tabs)</p>
<p>Also, as a tip, you can use Ctrl+shift+space to complete variables in your file.</p>
<p><strong>[edit]</strong><br />
More posts about Notepad++ can be found here: <a title="Notepad++ tag on Skypher.com" href="http://skypher.com/index.php/tag/notepad/">Notepad++  customization</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2008/04/16/notepad-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
