<?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: Strings and Output in PHP</title> <atom:link href="http://tinsology.net/2009/05/strings-and-output-in-php/feed/" rel="self" type="application/rss+xml" /><link>http://tinsology.net/2009/05/strings-and-output-in-php/</link> <description>Searching for the Right Questions</description> <lastBuildDate>Sat, 18 Feb 2012 21:34:20 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Tinsley</title><link>http://tinsology.net/2009/05/strings-and-output-in-php/comment-page-1/#comment-3803</link> <dc:creator>Tinsley</dc:creator> <pubDate>Sat, 13 Nov 2010 22:45:35 +0000</pubDate> <guid
isPermaLink="false">http://tinsology.net/?p=665#comment-3803</guid> <description>I&#039;ve always considered the &#039;best practice&#039; to be the one that yields the best code. Unless of course you&#039;re working with embedded systems or high performance applications (none of which should involve PHP).</description> <content:encoded><![CDATA[<p>I&#8217;ve always considered the &#8216;best practice&#8217; to be the one that yields the best code. Unless of course you&#8217;re working with embedded systems or high performance applications (none of which should involve PHP).</p> ]]></content:encoded> </item> <item><title>By: Spencer Drager</title><link>http://tinsology.net/2009/05/strings-and-output-in-php/comment-page-1/#comment-3798</link> <dc:creator>Spencer Drager</dc:creator> <pubDate>Fri, 12 Nov 2010 19:03:38 +0000</pubDate> <guid
isPermaLink="false">http://tinsology.net/?p=665#comment-3798</guid> <description>Certainly, I agree it&#039;s not worth wasting development time... the actual performance increase is tiny considering how little time it takes to actually parse. I just like to try to go for the &quot;best practice&quot;, especially in cases like this where it takes no extra effort for one over the other.</description> <content:encoded><![CDATA[<p>Certainly, I agree it&#8217;s not worth wasting development time&#8230; the actual performance increase is tiny considering how little time it takes to actually parse. I just like to try to go for the &#8220;best practice&#8221;, especially in cases like this where it takes no extra effort for one over the other.</p> ]]></content:encoded> </item> <item><title>By: Tinsley</title><link>http://tinsology.net/2009/05/strings-and-output-in-php/comment-page-1/#comment-3792</link> <dc:creator>Tinsley</dc:creator> <pubDate>Thu, 11 Nov 2010 03:08:59 +0000</pubDate> <guid
isPermaLink="false">http://tinsology.net/?p=665#comment-3792</guid> <description>I may have jumped the gun when assuming that concatenation was faster than outputting. In Java I&#039;ve had issues in the past with repeated calls to System.out for applications with a large amount of output. In this case it is clearly better to concatenate strings rather than output right away. The difference here is that in Java when you call System.out.print the data output immediately so the overhead of doing output is compounded. In PHP the output is buffered.
My benchmarks (PHP 5.3.2 running on Windows 7) still show that concatenating is faster than calling echo repeatedly, but only by a tiny margin. In any case, if you&#039;re spending any actual development time trying to decide whether to concatenate strings or call echo you&#039;re just wasting that time.
Edit: When I refer to Java I&#039;m talking about console applications, obviously output can be buffered in Java as well.</description> <content:encoded><![CDATA[<p>I may have jumped the gun when assuming that concatenation was faster than outputting. In Java I&#8217;ve had issues in the past with repeated calls to System.out for applications with a large amount of output. In this case it is clearly better to concatenate strings rather than output right away. The difference here is that in Java when you call System.out.print the data output immediately so the overhead of doing output is compounded. In PHP the output is buffered.</p><p>My benchmarks (PHP 5.3.2 running on Windows 7) still show that concatenating is faster than calling echo repeatedly, but only by a tiny margin. In any case, if you&#8217;re spending any actual development time trying to decide whether to concatenate strings or call echo you&#8217;re just wasting that time.</p><p>Edit: When I refer to Java I&#8217;m talking about console applications, obviously output can be buffered in Java as well.</p> ]]></content:encoded> </item> <item><title>By: Spencer Drager</title><link>http://tinsology.net/2009/05/strings-and-output-in-php/comment-page-1/#comment-3791</link> <dc:creator>Spencer Drager</dc:creator> <pubDate>Wed, 10 Nov 2010 18:29:05 +0000</pubDate> <guid
isPermaLink="false">http://tinsology.net/?p=665#comment-3791</guid> <description>Hmm... I guess I&#039;ve been out of the game for a while. It used to be that echo with commas was significantly faster than concatonation. Now it is not as much the case, but it is still true.
Goto http://www.phpbench.com/
and look at
$a = &#039;aaaaaaa&#039;;
echo $a.$a.$a.$a
vs
$a = &#039;aaaaaaa&#039;;
echo $a,$a,$a,$a
The latter will do better 95% of the time. Concatination does better when dealing with literals only and not $variables, but who concatinates literal strings instead of combining them into one string? Not I.</description> <content:encoded><![CDATA[<p>Hmm&#8230; I guess I&#8217;ve been out of the game for a while. It used to be that echo with commas was significantly faster than concatonation. Now it is not as much the case, but it is still true.</p><p>Goto <a
href="http://www.phpbench.com/" rel="nofollow">http://www.phpbench.com/</a><br
/> and look at</p><p>$a = &#8216;aaaaaaa&#8217;;<br
/> echo $a.$a.$a.$a</p><p>vs</p><p>$a = &#8216;aaaaaaa&#8217;;<br
/> echo $a,$a,$a,$a</p><p>The latter will do better 95% of the time. Concatination does better when dealing with literals only and not $variables, but who concatinates literal strings instead of combining them into one string? Not I.</p> ]]></content:encoded> </item> <item><title>By: Tinsley</title><link>http://tinsology.net/2009/05/strings-and-output-in-php/comment-page-1/#comment-3786</link> <dc:creator>Tinsley</dc:creator> <pubDate>Wed, 10 Nov 2010 14:12:10 +0000</pubDate> <guid
isPermaLink="false">http://tinsology.net/?p=665#comment-3786</guid> <description>First off if you think either way is significantly faster your definition of significant must be different from mine. The performance difference is negligible either way. My point was that you should focus on writing good code.
Can you point me to any of these sources? Until I see something authoritative saying otherwise, I&#039;m going to believe my own benchmarks.</description> <content:encoded><![CDATA[<p>First off if you think either way is significantly faster your definition of significant must be different from mine. The performance difference is negligible either way. My point was that you should focus on writing good code.</p><p>Can you point me to any of these sources? Until I see something authoritative saying otherwise, I&#8217;m going to believe my own benchmarks.</p> ]]></content:encoded> </item> <item><title>By: Spencer Drager</title><link>http://tinsology.net/2009/05/strings-and-output-in-php/comment-page-1/#comment-3785</link> <dc:creator>Spencer Drager</dc:creator> <pubDate>Wed, 10 Nov 2010 13:55:19 +0000</pubDate> <guid
isPermaLink="false">http://tinsology.net/?p=665#comment-3785</guid> <description>&quot;the answer is the former; concatenating strings is faster than doing output.&quot;
WRONG!
I&#039;ve seen many sources say echo-ing is significantly faster than concatenating, and my own tests have agreed.
If you got this wrong, I don&#039;t know what else you may have gotten wrong :/</description> <content:encoded><![CDATA[<p>&#8220;the answer is the former; concatenating strings is faster than doing output.&#8221;</p><p>WRONG!</p><p>I&#8217;ve seen many sources say echo-ing is significantly faster than concatenating, and my own tests have agreed.</p><p>If you got this wrong, I don&#8217;t know what else you may have gotten wrong :/</p> ]]></content:encoded> </item> </channel> </rss>
