<?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>David Carrington &#187; PHP</title>
	<atom:link href="http://davidcarrington.co.uk/category/development/php-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://davidcarrington.co.uk</link>
	<description>UK web developer that loves phones</description>
	<lastBuildDate>Thu, 22 Jul 2010 11:19:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>PHP needles and haystacks</title>
		<link>http://davidcarrington.co.uk/2010/07/php-needles-and-haystack/</link>
		<comments>http://davidcarrington.co.uk/2010/07/php-needles-and-haystack/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 07:19:40 +0000</pubDate>
		<dc:creator>David Carrington</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://davidcarrington.co.uk/?p=359</guid>
		<description><![CDATA[I was skim reading  &#8221;PHP &#8211; The Good Parts&#8221; yesterday to see if there was anything new in it. The following lines caught my eye – never knew this! The position of needle/haystack parameters in string functions is the reverse of the parameters in array functions. strstr($haystack, $needle) array_search($needle, $haystack) I just assumed the developers [...]]]></description>
			<content:encoded><![CDATA[<p>I was skim reading  &#8221;<a href="http://www.amazon.co.uk/gp/product/0596804377?ie=UTF8&amp;tag=davidcarri-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=0596804377">PHP &#8211; The Good Parts</a>&#8221; yesterday to see if there was anything new in it. The following lines caught my eye – never knew this!</p>
<p><strong>The position of needle/haystack parameters in string functions is the reverse of the parameters in array functions.</strong></p>
<p><strong> </strong></p>
<p><strong>strstr($haystack, $needle)<br />
</strong><strong>array_search($needle, $haystack)</strong></p>
<p><strong> </strong></p>
<p>I just assumed the developers were completely insane and chose parameter orders at random.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidcarrington.co.uk/2010/07/php-needles-and-haystack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Mobile Analytics and Opera Mini</title>
		<link>http://davidcarrington.co.uk/2009/12/google-mobile-analytics-and-opera-mini/</link>
		<comments>http://davidcarrington.co.uk/2009/12/google-mobile-analytics-and-opera-mini/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 22:36:12 +0000</pubDate>
		<dc:creator>David Carrington</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Opera Mini]]></category>

		<guid isPermaLink="false">http://davidcarrington.co.uk/?p=175</guid>
		<description><![CDATA[Google Analytics is a popular web statistics site with lots of useful features, I&#8217;ve been a big fan since the start. Google recently added a bunch of new features, and an important one out of those for me is mobile web tracking. Typically, Google&#8217;s way of tracking site usage is to ask you to put [...]]]></description>
			<content:encoded><![CDATA[<p>Google Analytics is a popular web statistics site with lots of useful features, I&#8217;ve been a big fan since the start. Google <a href="http://analytics.blogspot.com/2009/12/holiday-bonus-more-great-features.html">recently added</a> a bunch of new features, and an important one out of those for me is <em>mobile web tracking</em>.</p>
<p>Typically, Google&#8217;s way of tracking site usage is to ask you to put a small snippet of HTML onto your site which is essentially a javascript call to their servers. Great &#8211; except a lot of mobile phones don&#8217;t actually support javascript. So the only good solution is to run some code on the server. I don&#8217;t know if it&#8217;s related to <a href="http://googleblog.blogspot.com/2009/11/investing-in-mobile-future-with-admob.html">Google&#8217;s purchase of AdMob</a>, but they&#8217;ve done exactly that and provided server side code in various programming languages (C#, PHP, etc) to achieve this. See <a href="https://ssl.gstatic.com/analytics/20091201/mobile/ga.php">ga.php</a> as a real example.</p>
<p>Great, now I&#8217;ve got beautiful graphs showing me how people use my site. But what&#8217;s that? 25% of my users live in the country <em>(not set)</em>? I&#8217;ve not heard of the place! It turns out those users more or less all used one browser: Opera Mini.</p>
<p><a href="http://www.flickr.com/photos/thox/4172396551/"><img class="alignright" title="Photo of Opera Mini looking at dabr.co.uk" src="http://farm3.static.flickr.com/2644/4172396551_09fa706773_m.jpg" alt="" width="180" height="240" /></a>Oh Opera Mini, what a strange beast you are. While the Opera browser is a full normal browser, Opera Mini is a service that installs a thin client on your phone and Norwegian proxy servers visit the site for you. Norway? Well that&#8217;s a little better than living in <em>(not set)</em>.</p>
<p>Luckily, this whole problem is fixed by a teensy change in their server side code. Rather than always fetching the browser&#8217;s current IP address, I tweaked Google&#8217;s PHP code so that it detects Opera Mini is in use and sends the real user&#8217;s IP address. To be honest, I&#8217;m a little confused why this isn&#8217;t in Google&#8217;s code in the first place.</p>
<p>So here it is. A minor fix to Google&#8217;s ga.php file (line 162) to improve Opera Mini handling:</p>
<p>Original line: <code>"&amp;utmip=" . getIP($_SERVER["REMOTE_ADDR"]);</code></p>
<p>and my version: <code> "&amp;utmip=" . getIP((stristr($_SERVER['HTTP_USER_AGENT'], 'opera mini') &amp;&amp; array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) ? $_SERVER['HTTP_X_FORWARDED_FOR']: $_SERVER["REMOTE_ADDR"]);</code></p>
<p>That&#8217;s all. Now I get real country stats :)</p>
]]></content:encoded>
			<wfw:commentRss>http://davidcarrington.co.uk/2009/12/google-mobile-analytics-and-opera-mini/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tracking my phone on Google Earth</title>
		<link>http://davidcarrington.co.uk/2007/11/tracking-my-phone-on-google-earth/</link>
		<comments>http://davidcarrington.co.uk/2007/11/tracking-my-phone-on-google-earth/#comments</comments>
		<pubDate>Mon, 12 Nov 2007 23:06:10 +0000</pubDate>
		<dc:creator>David Carrington</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Google Earth]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[KML]]></category>
		<category><![CDATA[Windows Mobile]]></category>

		<guid isPermaLink="false">http://davidcarrington.co.uk/2007/11/12/tracking-my-phone-on-google-earth/</guid>
		<description><![CDATA[After looking through various KML samples on the web during lunch today, I spent a little time experimenting with converting my existing location data into something that Google Earth could read &#8211; allowing people to track my location in real time. Manual labour About 6 times per day, I press a button on my phone [...]]]></description>
			<content:encoded><![CDATA[<p>After looking through various KML samples on the web during lunch today, I spent a little time experimenting with converting my existing location data into something that Google Earth could read &#8211; allowing people to track my location in real time.</p>
<p><strong>Manual labour</strong></p>
<p>About 6 times per day, I press a button on my phone and it sends a text message to my website with my current cell tower ID. My website then takes over and does all the smart stuff by itself. If I&#8217;ve traveled somewhere new, it automatically looks up the cell ID in a large UK database using their API to find the latitude and longitude of the cell tower I&#8217;m currently connected to. But big decimal numbers showing my current latitude and longitude aren&#8217;t all that interesting on their own.</p>
<p><strong>Sidebar widget</strong></p>
<p>The next step in my process was to add the widget on the side of my website to show everyone my current location. It&#8217;s not particularly fascinating &#8211; either I&#8217;m in my home town, at work, or traveling somewhere in between. But I&#8217;ve just added something a little more interesting.</p>
<p><strong>Google Earth</strong></p>
<p>Whereas before the link on my current location just took you to the coordinates where I&#8217;m currently sat, it will now load up a KML file showing a nice picture of a man standing on my current location, and hopefully a number of little cell towers which will show where I&#8217;ve been over the last 7 days.</p>
<p>The historic data isn&#8217;t all that interesting in Google Maps, but if I open up my KML file in Google Earth then I expose the timeline controls and I can choose to see where I was at different times and even animate my location over time.</p>
<p><strong>What&#8217;s next?</strong></p>
<p>I&#8217;ve got a habit of always wanting to do more.  I&#8217;ve cleaned up my location database so I could add in other locations (i.e. not just cell towers) and try plotting even more data. I&#8217;d like to try the following:</p>
<ul>
<li>Load up GPS data for any hikes I go on</li>
<li>Add a few key locations onto the map such as the Scout hut, my brother&#8217;s place in Canada, anything relevant to me</li>
<li>Add some kind of refresh so that it updates automatically when I&#8217;m on the move</li>
<li>Create some kind of JavScript timeline interface for Google Maps</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://davidcarrington.co.uk/2007/11/tracking-my-phone-on-google-earth/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Keeping programming knowledge alive</title>
		<link>http://davidcarrington.co.uk/2007/10/keeping-programming-knowledge-alive/</link>
		<comments>http://davidcarrington.co.uk/2007/10/keeping-programming-knowledge-alive/#comments</comments>
		<pubDate>Wed, 24 Oct 2007 12:47:36 +0000</pubDate>
		<dc:creator>David Carrington</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://davidcarrington.co.uk/2007/10/24/keeping-programming-knowledge-alive/</guid>
		<description><![CDATA[I&#8217;ve read a few articles about spoken languages across the globe fading to non-existance because no one speaks them any more and they get forgotten. &#8220;More than half of the word&#8217;s 7000 languages are endangered, because they consist of an unsustainably small – and declining – speaker base.&#8221; &#8211; New Scientist On a much less [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve read a few articles about spoken languages across the globe fading to non-existance because no one speaks them any more and they get forgotten.</p>
<blockquote><p>&#8220;More than half of the word&#8217;s 7000 languages are endangered, because they consist of an unsustainably small – and declining – speaker base.&#8221; &#8211; New Scientist</p></blockquote>
<p>On a much less epic scale, I&#8217;m concerned about my own knowledge of programming languages fading to nothing from lack of use. The best example for me is Perl.</p>
<p>Perl is the first server-side programming language I tried to learn to improve my websites. I made very basic guestbook scripts and that was about it, but I did (for a short time) know the syntax and some basic principles in the language. I&#8217;ve not used Perl for <em>5 years</em>!</p>
<p>I started looking into PHP, and never looked back. So what do I remember of Perl now? Hardly anything at all.</p>
<p>With a few years of self-taught PHP under my belt, I&#8217;m now pushing slowly into ASP.NET. This time, I&#8217;m going to keep my PHP very much alive.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidcarrington.co.uk/2007/10/keeping-programming-knowledge-alive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
