<?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: Speed Comparison of strlen() VS empty() in PHP Shows empty() is Faster</title>
	<atom:link href="http://randomdrake.com/2009/10/08/speed-comparison-of-strlen-vs-empty-in-php-shows-empty-is-faster/feed/" rel="self" type="application/rss+xml" />
	<link>http://randomdrake.com/2009/10/08/speed-comparison-of-strlen-vs-empty-in-php-shows-empty-is-faster/</link>
	<description>David Drake Covers Programming, Technology and Turbulence in Life</description>
	<lastBuildDate>Sat, 04 Feb 2012 20:52:22 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: electric egg cooker</title>
		<link>http://randomdrake.com/2009/10/08/speed-comparison-of-strlen-vs-empty-in-php-shows-empty-is-faster/comment-page-1/#comment-14628</link>
		<dc:creator>electric egg cooker</dc:creator>
		<pubDate>Mon, 19 Oct 2009 06:26:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.ilovebonnie.net/?p=350#comment-14628</guid>
		<description>Every time i come here I am not disappointed, nice post!

Greetings from Tim. :)</description>
		<content:encoded><![CDATA[<p>Every time i come here I am not disappointed, nice post!</p>
<p>Greetings from Tim. <img src='http://randomdrake.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Avatar</title>
		<link>http://randomdrake.com/2009/10/08/speed-comparison-of-strlen-vs-empty-in-php-shows-empty-is-faster/comment-page-1/#comment-14298</link>
		<dc:creator>Avatar</dc:creator>
		<pubDate>Thu, 08 Oct 2009 18:24:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.ilovebonnie.net/?p=350#comment-14298</guid>
		<description>I don&#039;t believe it is generally cost-effective to streamline code by searching for constructs that give minor performance gains.  Especially prickly to me are changes that make unclear your intentions to the next programmer, not that this post is one of those cases.  It is worth noting that your test script executes in less than 0.25s on my crappy environment.  If I were looking at this are part of a real program, I&#039;d be questioning if I had to loop 100 times way before I questioned empty() vs isset().

But, rather than pontificating, I&#039;ll get back to the the subject at hand.  My preference has always been to use the logical operator ! instead of strlen(), empty(), isset(), or other.  Only in the cases where I expect an actual false value, of any type, will I use something else.  It stacks up okay in your speed test:

Checking &quot;if (!strlen($string))&quot; VS &quot;if ( !$string)&quot;

unset($string);
Average speed gain using empty() instead of strlen(): 54.34%
Number of times where strlen() was actually faster: 4

$string === false;
Average speed gain using empty() instead of strlen(): 67.63%

$string = &#039;&#039;;
Average speed gain using empty() instead of strlen(): 56.1%</description>
		<content:encoded><![CDATA[<p>I don&#8217;t believe it is generally cost-effective to streamline code by searching for constructs that give minor performance gains.  Especially prickly to me are changes that make unclear your intentions to the next programmer, not that this post is one of those cases.  It is worth noting that your test script executes in less than 0.25s on my crappy environment.  If I were looking at this are part of a real program, I&#8217;d be questioning if I had to loop 100 times way before I questioned empty() vs isset().</p>
<p>But, rather than pontificating, I&#8217;ll get back to the the subject at hand.  My preference has always been to use the logical operator ! instead of strlen(), empty(), isset(), or other.  Only in the cases where I expect an actual false value, of any type, will I use something else.  It stacks up okay in your speed test:</p>
<p>Checking &#8220;if (!strlen($string))&#8221; VS &#8220;if ( !$string)&#8221;</p>
<p>unset($string);<br />
Average speed gain using empty() instead of strlen(): 54.34%<br />
Number of times where strlen() was actually faster: 4</p>
<p>$string === false;<br />
Average speed gain using empty() instead of strlen(): 67.63%</p>
<p>$string = &#8221;;<br />
Average speed gain using empty() instead of strlen(): 56.1%</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 3.893 seconds -->

