<?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>meier-online &#187; Traps</title>
	<atom:link href="http://meier-online.com/tag/fallen/feed/" rel="self" type="application/rss+xml" />
	<link>http://meier-online.com</link>
	<description>Der Blog von Karsten Meier</description>
	<lastBuildDate>Sun, 09 Oct 2011 13:27:57 +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>(Deutsch) Eins plus Zwei</title>
		<link>http://meier-online.com/en/2010/12/one-plus_two/</link>
		<comments>http://meier-online.com/en/2010/12/one-plus_two/#comments</comments>
		<pubDate>Thu, 30 Dec 2010 17:42:11 +0000</pubDate>
		<dc:creator>meier</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Traps]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Typumwandlung]]></category>

		<guid isPermaLink="false">http://meier-online.com/?p=726</guid>
		<description><![CDATA[Sorry, this entry is only available in Deutsch.]]></description>
			<content:encoded><![CDATA[<p>Sorry, this entry is only available in <a href="http://meier-online.com/tag/fallen/feed/">Deutsch</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://meier-online.com/en/2010/12/one-plus_two/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Compare Strings with PHP</title>
		<link>http://meier-online.com/en/2008/11/vergleich-von-strings-in-php/</link>
		<comments>http://meier-online.com/en/2008/11/vergleich-von-strings-in-php/#comments</comments>
		<pubDate>Sun, 23 Nov 2008 16:48:00 +0000</pubDate>
		<dc:creator>meier</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Traps]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Strings]]></category>

		<guid isPermaLink="false">http://meier-online.com/blog/?p=158</guid>
		<description><![CDATA[In my programming work I often switch between different programming languages. It&#8217;s not so difficult, but problems sometimes appear just at very simple things. Strings in PHP are really easy to compare, there is the &#8220;==&#8221; operator. But there lurks a trap: If either of the operands is not a string, there is an automatic [...]]]></description>
			<content:encoded><![CDATA[<p>In my programming work I often switch between different programming languages. It&#8217;s not so difficult, but problems sometimes appear just at very simple things.</p>
<p>Strings in PHP are really easy to compare, there is the &#8220;==&#8221; operator. But there lurks a trap: <span id="more-158"></span>If either of the operands is not a string, there is an automatic conversation. And that can sometimes be different than the one you expect.</p>
<p>0 == &#8220;hello&#8221; returns true because &#8220;hello&#8221; is converted in a number with the value of 0. This gets brisant when the 0 return value was a from function that normally returns a string, and a 0 in case of errors. If the programmer is not aware about it, then the program behaves differently than expected, and precisely in case of errors, which is mostly not as well tested.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$cmd</span> <span style="color: #339933;">=</span> getCommandFromUser<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$cmd</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;deleteTable&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
deleteDatabaseTables<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In PHP there is also the operator with three equal signs, &#8220;===&#8221;. In PHP this first tests whether both operands have the same type.</p>
<p>So you can use thisoperator in such cases. Well, I think that the tripple equal sign is quite a hack, even the double equal sign is mathematically questionable. The === operator is often just  put in languages, if somehow still another comparison operator is required,. And the semantics in any programming language is different &#8230;</p>
<p>Another possibility is to use strcmp () and strcasecmp (). The second is useful if the upper / lower case letters should be ignored. Bu again you have to be careful: the function returns 0 if the strings are equal, in other contexts the 0 is &#8220;False&#8221; . So the code again gets confusing:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">==</span> <span style="color: #990000;">strcasecmp</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cmd</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;deleteTable&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #339933;">...</span><span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://meier-online.com/en/2008/11/vergleich-von-strings-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

