<?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>For what IT worths &#187; php</title>
	<atom:link href="http://www.forwhatitworths.com/posts/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.forwhatitworths.com</link>
	<description>taking I.T. personally</description>
	<lastBuildDate>Thu, 20 May 2010 23:30:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The character, which is not</title>
		<link>http://www.forwhatitworths.com/posts/2007/07/the-character-which-is-not/</link>
		<comments>http://www.forwhatitworths.com/posts/2007/07/the-character-which-is-not/#comments</comments>
		<pubDate>Sun, 15 Jul 2007 07:39:54 +0000</pubDate>
		<dc:creator>tamasdecsi</dc:creator>
				<category><![CDATA[debugging]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.forwhatitworths.com/?p=9</guid>
		<description><![CDATA[I was busy integrating a search keyword-based advertising solution into one of our clients&#8217; site some day last week. It seemed like a no-brainer task: communication was handled by a neatly implemented php script provided by the peer company, along with a pdf document describing all what need to be programmed with lots of examples, [...]]]></description>
			<content:encoded><![CDATA[<p>I was busy integrating a search keyword-based advertising solution into one of our clients&#8217; site some day last week. It seemed like a no-brainer task: communication was handled by a neatly implemented php script provided by the peer company, along with a pdf document describing all what need to be programmed with lots of examples, created for dummies.</p>
<p>As lazy as one can be, I tried to save a few minutes by copy-pasting five relevant code lines from this pdf manual, and only changing the necessary parts to fit into the site&#8217;s code base.</p>
<p>Think of something as simple as</p>
<blockquote><p><code>...<br />
require_once('peer_code.class.php');<br />
$s = new peerCodeClass();<br />
$s-&gt;search($keyword);<br />
foreach ( $s-&gt;results as $result)<br />
...</code></p></blockquote>
<p>Done, great. Give it a go. Kaboom.</p>
<p>It just didn&#8217;t work. The error log kept saying <em>&#8220;Call to undefined function:  search()&#8221;</em>. Darn.</p>
<p>I don&#8217;t count php as one of my favorite languages, partly because its lack of a decent debugger. So I needed to stick to tricks like echo-ing variable values at certain points of the code, and raising error_reporting level to maximum.</p>
<p>So it seemed that the class does get instantiated, and $s contains a fully equipped peerCodeClass. What&#8217;s wrong then? Why does it keep telling me that search() is undefined?</p>
<p>I&#8217;ve checked for every minuscule warning in the error log, and fixed the code so that even the pragmatic compiler could say nothing wrong to that. I even started renaming variables and function names to avoid any hidden name clash possibilities. Still nothing. I was about to start believing in trolls, when my eyes caught one strange character in one of the error log entries. It said <em>&#8220;Undefined variable:  s­- in &#8230;&#8221;</em></p>
<p>A suspicion slowly crept into my mind. No that can&#8217;t be just it! I quickly retyped that one line with the $s-&gt;search(); and gave it another go. Bingo! It worked this time!</p>
<p>Folks, copy-pasting from pdf into console may result in character-alikes that are in fact something else. In my case, I&#8217;ll never know what sort of dash was in there, but definitely not the ASCII dash, which the compiler expected.</p>
<p>Doing the math, by copy-pasting that small piece of code I&#8217;ve saved maybe 2 minutes, only to lose 2 hours for debugging. When writing code, copy-paste is evil, and not just the usual &#8211; uh, forgot to update the parts that differ &#8211; way!</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.forwhatitworths.com%2Fposts%2F2007%2F07%2Fthe-character-which-is-not%2F&amp;title=The+character%2C+which+is+not" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.forwhatitworths.com%2Fposts%2F2007%2F07%2Fthe-character-which-is-not%2F&amp;title=The+character%2C+which+is+not" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.forwhatitworths.com%2Fposts%2F2007%2F07%2Fthe-character-which-is-not%2F&amp;title=The+character%2C+which+is+not" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.forwhatitworths.com%2Fposts%2F2007%2F07%2Fthe-character-which-is-not%2F&amp;title=The+character%2C+which+is+not" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.forwhatitworths.com%2Fposts%2F2007%2F07%2Fthe-character-which-is-not%2F&amp;title=The+character%2C+which+is+not', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.forwhatitworths.com%2Fposts%2F2007%2F07%2Fthe-character-which-is-not%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.forwhatitworths.com%2Fposts%2F2007%2F07%2Fthe-character-which-is-not%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.forwhatitworths.com%2Fposts%2F2007%2F07%2Fthe-character-which-is-not%2F&amp;title=The+character%2C+which+is+not" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.forwhatitworths.com%2Fposts%2F2007%2F07%2Fthe-character-which-is-not%2F&amp;title=The+character%2C+which+is+not" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.forwhatitworths.com/posts/2007/07/the-character-which-is-not/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
