<?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>Henrik Falck&#039;s blog &#187; php</title>
	<atom:link href="http://henrikfalck.com/blog/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://henrikfalck.com/blog</link>
	<description>reinventing web 3.0</description>
	<lastBuildDate>Mon, 12 Apr 2010 00:33:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Localization support for language identifier</title>
		<link>http://henrikfalck.com/blog/2010/04/localization-support-for-language-identifier.html</link>
		<comments>http://henrikfalck.com/blog/2010/04/localization-support-for-language-identifier.html#comments</comments>
		<pubDate>Sun, 11 Apr 2010 03:18:40 +0000</pubDate>
		<dc:creator>Henrik Falck</dc:creator>
				<category><![CDATA[projects]]></category>
		<category><![CDATA[improvements]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[language analyzer]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web apps]]></category>

		<guid isPermaLink="false">http://henrikfalck.com/blog/?p=370</guid>
		<description><![CDATA[Something&#8217;s wrong when a language identifier doesn&#8217;t have localization support. So I cooked up a little localization code for What Language Is This?, which proved to be not as easy as one might guess. That&#8217;s because some of the textual content of the web app is in HTML, other is generated by PHP, and yet [...]]]></description>
			<content:encoded><![CDATA[<p>Something&#8217;s wrong when a language identifier doesn&#8217;t have localization support. So I cooked up a little localization code for <a href="http://whatlanguageisthis.com/" title="What Language Is This? Online language identifier"  target="_blank">What Language Is This?</a>, which proved to be not as easy as one might guess. That&#8217;s because some of the textual content of the web app is in HTML, other is generated by PHP, and yet other is generated in JavaScript. I wanted to have one single source of localized strings for all three output paths to simplify overviewing, translating, changing, and adding strings to the web app.</p>
<p>I&#8217;m not sure if there&#8217;s any good solution for this out there, but I cooked up my own. Each language translation has its strings in a text file formatted like an ini file with id keys and localized strings separated by an equals sign. You can view the <a href="http://whatlanguageisthis.com/strings-en.txt"  target="_blank">English</a> and <a href="http://whatlanguageisthis.com/strings-ja.txt"  target="_blank">Japanese</a> raw text files if you like. These are read into a PHP array (i.e. dictionary), after first looking at what language is specified by the URL (/en for English, /ja for Japanese or any other code), and if that is not specified then looking at what languages the browser is set to prefer via the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4"  target="_blank">Accept-Language</a> HTTP header. If the requested language is not available then default to English.</p>
<p>To get the html output localized, the php script that reads through and configures the app (the plain html file itself is set up to run offline for debugging purposes only) looks for string ids enclosed in percent signs, i.e. like %strings id%. These are then replaced with the localized strings from the dictionary. The php-generated content is trivially changed to look up strings from the dictionary. On the JavaScript side, I wanted access to the same string dictionary that I had on the php side, so this is inserted into a &lt;script&gt; block of the generated html output as a JavaScript object (i.e. dictionary). String id lookups can then be done on this object from the JavaScript code just like on the php side. In other words, the php string dictionary is converted into JSON, which is used from the JavaScript side.</p>
<div id="attachment_371" class="wp-caption aligncenter" style="width: 310px"><a href="http://henrikfalck.com/blog/wp-content/uploads/2010/04/wlit-japanese.jpg" ><img class="size-medium wp-image-371" title="あれ何語？ What Language Is This? in 日本語" src="http://henrikfalck.com/blog/wp-content/uploads/2010/04/wlit-japanese-300x186.jpg" alt="あれ何語？ What Language Is This? in 日本語" width="300" height="186" /></a><p class="wp-caption-text">あれ何語？ What Language Is This? in 日本語</p></div>
<p>It all works pretty well and meets my goals. The only downside is that it relies on the server to do some processing, so when I develop on the offline version the strings aren&#8217;t available, instead I get to see the raw string ids, which can be useful too, but you have to rely on imagination to envision the end result. Isn&#8217;t programming always like that anyway, though?</p>
<p>The first translated version of What Language Is This? is of course <a href="http://whatlanguageisthis.com/ja" title="ウェブ上言語識別サービス"  target="_blank">Japanese</a>, done by myself and my wife (初めての共同作業? lol), not just because it&#8217;s easy for me to do, but also because when looking at the <a href="http://addthis.com/"  target="_blank">AddThis</a> stats, Japan is the top ranking country, and also as you know the average English skills in Japan are pretty bad, so I suspect there is a demand for a Japanese translation. Looking at the access stats, and discounting those with good English skills (India, Netherlands, Scandinavia, for example), next in line would most likely be Spanish, French, and German, in that order. Anyone feel like helping? Please drop me a comment in that case. I can offer proper credit and a link back from the site in return.</p>
]]></content:encoded>
			<wfw:commentRss>http://henrikfalck.com/blog/2010/04/localization-support-for-language-identifier.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>We&#8217;ll Always Have C</title>
		<link>http://henrikfalck.com/blog/2008/04/well-always-have-c.html</link>
		<comments>http://henrikfalck.com/blog/2008/04/well-always-have-c.html#comments</comments>
		<pubDate>Sat, 26 Apr 2008 04:02:00 +0000</pubDate>
		<dc:creator>Henrik Falck</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://henrikfalck.com/blog2/2008/04/well-always-have-c.html</guid>
		<description><![CDATA[The other day there was an interview in Dr. Dobb&#8217;s Journal with the managing director of TIOBE Software, who publishes the TIOBE Programming Community Index, a ranking of programming language popularity. It was also discussed on Slashdot.
The methodology used by TIOBE to calculate a language&#8217;s popularity is basically the good old google hits ad-hoc voodoo [...]]]></description>
			<content:encoded><![CDATA[<p>The other day there was an <a href="http://www.ddj.com/development-tools/207401593" >interview in Dr. Dobb&#8217;s Journal</a> with the <span style="font-weight: bold;">managing director of TIOBE Software</span>, who publishes the <a href="http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html" style="font-weight: bold;" >TIOBE Programming Community Index</a>, a ranking of <span style="font-weight: bold;">programming language popularity</span>. It was also <a href="http://tech.slashdot.org/article.pl?sid=08/04/24/1955257" >discussed on Slashdot</a>.</p>
<p>The <a href="http://www.tiobe.com/index.php/content/paperinfo/tpci/tpci_definition.htm" >methodology used by TIOBE</a> to calculate a language&#8217;s popularity is basically the <span style="font-weight: bold;">good old google hits ad-hoc voodoo index</span>, using &#8220;<language name="">[language] programming&#8221; as the query. This measures the <span style="font-weight: bold; font-style: italic;">&#8220;web presence&#8221;</span> of a programming language.</p>
<p>First of all, it&#8217;s obvious to you and me that this measures something, that something being the amount of web pages including the term &#8220;<language name="">[language] programming&#8221;, obviously. There&#8217;s nothing wrong with this method, as long as one is aware of what they&#8217;re measuring. But is it fair to call this the popularity of a language?</p>
<p></language></language><a href="http://blog.rvburke.com/wp-content/uploads/2006/10/gary-larson-oct-1987.gif" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" ><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px;" src="http://blog.rvburke.com/wp-content/uploads/2006/10/gary-larson-oct-1987.gif" alt="" border="0" /></a><br /><language name=""><language name=""><span style="font-weight: bold; font-style: italic;">Look at this blog, for example.</span> I mostly mention <span style="font-weight: bold;">JavaScript</span> and <span style="font-weight: bold;">PHP</span> here, just like everyone else. Throw in some <span style="font-weight: bold;">Ruby</span> and <span style="font-weight: bold;">Python</span> too to max out the buzz factor. There is no mention of relics such as C in this blog. <span style="font-weight: bold; font-style: italic;">But you know what language I use ten times more than any other?</span> C. I&#8217;d love to have a job hacking away in JavaScript, Ruby, and Python all days, <span style="font-weight: bold; font-style: italic;">but I&#8217;d have to settle with half the salary.</span> <span style="font-style: italic;">So here it goes:</span> <span style="font-weight: bold;">C programming</span>. Index that. <span style="font-style: italic;">Embedded, heavily multi-threaded, efficient, minimum memory, hardcore badass C programming</span>, that&#8217;s what I do, and I love doing it.</p>
<p></language></language><language name=""><language name="">Most coders can&#8217;t do C. <span style="font-weight: bold; font-style: italic;">That&#8217;s why you see all these Visual This and Dot That</span> and <span style="font-weight: bold;">scripting languages</span> on the ranking, because these kids blog about every little insignificant hobby project they manage to cut and paste together, just like I do. But let there be no mistake about it:<span style="font-weight: bold; font-style: italic;"> real programmers can code in C</span>. They do <span style="font-weight: bold; font-style: italic;">syntactically correct typedefs of function pointers in their sleep</span>. <span style="font-size:85%;">(just kidding that&#8217;s impossible.)</span></p>
<p></language></language><a href="http://existentialtype.net/wp-content/uploads/2007/05/im-in-ur-stackz-overflowing-ur-bufferz.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" ><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px;" src="http://existentialtype.net/wp-content/uploads/2007/05/im-in-ur-stackz-overflowing-ur-bufferz.jpg" alt="" border="0" /></a><br /><language name=""><language name=""><span style="font-weight: bold;">At work</span> I also hack in Python, Perl, and Makefile. <span style="font-weight: bold;">At home</span> it&#8217;s mostly JavaScript, PHP, Ruby, Python&#8230; <span style="font-weight: bold; font-style: italic;">Lately Python has replaced Ruby as my language of choice</span> for home hacking because of its <span style="font-weight: bold;">decent unicode support</span>. (Although I&#8217;ve had to hack the Python standard library in some places where it didn&#8217;t properly support unicode. I read the next version of Python (2.6?) will use unicode strings by default, which is great, and only ten years late.) I also sold my soul the other day and installed <span style="font-weight: bold;">Visual C# 2008 Express Edition</span> for some hobby hacking. Turned out not very fun though, but I haven&#8217;t given up yet.</p>
<p>At my previous job I used C++ for doing essentially the same thing as I do in C now. I&#8217;m completely convinced that C is the right tool for the job. <span style="font-weight: bold; font-style: italic;">I&#8217;m also convinced C does object orientation better than C++</span>, but that is a topic for another post. And I <span style="font-weight: bold;">used to be a Java fan</span>, but now I&#8217;m considering Java the best examples of software suckiness ever. It&#8217;s a volatile industry, technologies come and go, but <span style="font-weight: bold; font-style: italic;">no amount of blogging will convince me that the C programming language is anything but #1</span>.</p>
<p>I&#8217;m saying it because it&#8217;s true: <span style="font-weight: bold;">We&#8217;ll always have C.</span> Because we&#8217;ve got jobs to do.<br /></language></language></p>
]]></content:encoded>
			<wfw:commentRss>http://henrikfalck.com/blog/2008/04/well-always-have-c.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Caching in Php</title>
		<link>http://henrikfalck.com/blog/2007/07/caching-in-php.html</link>
		<comments>http://henrikfalck.com/blog/2007/07/caching-in-php.html#comments</comments>
		<pubDate>Mon, 16 Jul 2007 04:16:00 +0000</pubDate>
		<dc:creator>Henrik Falck</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[www]]></category>

		<guid isPermaLink="false">http://henrikfalck.com/blog2/2007/07/caching-in-php.html</guid>
		<description><![CDATA[Php by default tries as hard as it can to make the web browser not cache pages. While I can understand the rationale behind this a bit, sometimes you want caching. Caching is actually a good thing! you know. It means faster load times and lower bandwidth and processing requirements.
So I was surprised by how [...]]]></description>
			<content:encoded><![CDATA[<p>Php by default tries as hard as it can to make the web browser <span style="font-weight: bold;">not</span> cache pages. While I can understand the rationale behind this a bit, sometimes you want caching. <span style="font-weight: bold; font-style: italic;">Caching</span> is actually a <span style="font-weight: bold; font-style: italic;">good thing</span><span style="font-style: italic;">!</span> you know. It means faster load times and lower bandwidth and processing requirements.</p>
<p>So I was surprised by <span style="font-weight: bold; font-style: italic;">how hard it is to turn off this aggressive non-caching policy</span>. I googled for a few minutes and browsed the php documentation without finding an easy way of doing it. Ok, so you can use the following code snippet to enable caching in php (the argument to the function is number of seconds the page is valid):<br /><code><br />function send_cache_headers($expire) {<br />&nbsp;&nbsp;header("Cache-Control: max-age=$expire");<br />&nbsp;&nbsp;header("Pragma: cache");<br />&nbsp;&nbsp;header("Expires: " . gmdate('D, d M Y H:i:s \G\M\T', time() + $expire));<br />}<br /></code></p>
]]></content:encoded>
			<wfw:commentRss>http://henrikfalck.com/blog/2007/07/caching-in-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A JavaScript messaging library</title>
		<link>http://henrikfalck.com/blog/2007/07/javascript-messaging-library.html</link>
		<comments>http://henrikfalck.com/blog/2007/07/javascript-messaging-library.html#comments</comments>
		<pubDate>Thu, 05 Jul 2007 12:03:00 +0000</pubDate>
		<dc:creator>Henrik Falck</dc:creator>
				<category><![CDATA[projects]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[messagelib]]></category>
		<category><![CDATA[paintmyblog]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web apps]]></category>

		<guid isPermaLink="false">http://henrikfalck.com/blog2/2007/07/a-javascript-messaging-library.html</guid>
		<description><![CDATA[I&#8217;m working on a library for sending messages between browsers using JavaScript, XMLHttpRequest, and PHP/sqlite on a server. The idea is that even though it&#8217;s not possible to open a connection of sorts directly between the clients (i.e. web browsers viewing a page, or even different pages, or running a widget), you can pull for [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on a library for sending messages between browsers using JavaScript, XMLHttpRequest, and PHP/sqlite on a server. The idea is that even though it&#8217;s not possible to open a connection of sorts directly between the clients (i.e. web browsers viewing a page, or even different pages, or running a widget), you can pull for updates in a way that will make it seem like you have a connection open. Not only that, but all client listening on the same channel, so to speak, will receive the messages, so it&#8217;s like broadcasting. Technically this is nothing fancy, it&#8217;s just that you don&#8217;t see it much, and if implemented and packaged nicely I think it&#8217;ll be useful and fun to use.</p>
<p>How do I know this works? Because it&#8217;s based on a much cleaned up version of the code used on <a href="http://paintmyblog.com/" >paintmyblog.com</a> &#8211; which has proven itself already. I look forward to writing some cool apps using this library, and I hope other people will use it as well. Expect the first release next week.</p>
]]></content:encoded>
			<wfw:commentRss>http://henrikfalck.com/blog/2007/07/javascript-messaging-library.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Note On PHP</title>
		<link>http://henrikfalck.com/blog/2007/06/note-on-php.html</link>
		<comments>http://henrikfalck.com/blog/2007/06/note-on-php.html#comments</comments>
		<pubDate>Mon, 25 Jun 2007 13:31:00 +0000</pubDate>
		<dc:creator>Henrik Falck</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[anecdote]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://henrikfalck.com/blog2/2007/06/a-note-on-php.html</guid>
		<description><![CDATA[Php is the most useful piece of crap ever shat on the face of the Earth. My old software engineering professor Uwe Aßmann (who held the by far best lectures I&#8217;ve ever had the pleasure to attend) used to call it Some Dude&#8217;s Law (I can&#8217;t remember whose) &#8211; that the ugly and worst designed [...]]]></description>
			<content:encoded><![CDATA[<p>Php is the most useful piece of crap ever shat on the face of the Earth. My old software engineering professor <a href="http://www.ida.liu.se/%7Euweas/" >Uwe Aßmann</a> (who held the by far best lectures I&#8217;ve ever had the pleasure to attend) used to call it Some Dude&#8217;s Law (I can&#8217;t remember whose) &#8211; that the ugly and worst designed software (Windows, PHP&#8230;) always win over the sexy and well designed (BeOS, Smalltalk&#8230;). Well, that&#8217;s how it is. Php makes me feel sick all the time, but I still use it. Because I have to (because that&#8217;s what&#8217;s installed) is only half the reason. The documentation is top notch, and I&#8217;m very productive using it. In Windows&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://henrikfalck.com/blog/2007/06/note-on-php.html/feed</wfw:commentRss>
		<slash:comments>55</slash:comments>
		</item>
	</channel>
</rss>

