<?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>php | Woody Hayday | Blog</title>
	<atom:link href="https://blog.woodylabs.com/tag/php-2/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.woodylabs.com</link>
	<description>An exploration of life, technology and writing</description>
	<lastBuildDate>Tue, 13 Jan 2015 15:19:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.woodylabs.com/wp-content/uploads/2015/01/cropped-woody-hayday-yosemite-glacier-point-32x32.jpg</url>
	<title>php | Woody Hayday | Blog</title>
	<link>https://blog.woodylabs.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Hotmail and Character Sets: Make Sure Your Emails Get There</title>
		<link>https://blog.woodylabs.com/2012/09/hotmail-and-character-sets-make-sure-your-emails-get-there/</link>
		
		<dc:creator><![CDATA[Woody]]></dc:creator>
		<pubDate>Wed, 19 Sep 2012 13:18:16 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[hotmail]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[web app prototypes]]></category>
		<category><![CDATA[web dev]]></category>
		<guid isPermaLink="false">http://blog.woodylabs.com/?p=916</guid>

					<description><![CDATA[<p>It&#8217;s been a hectic few months &#8211; the web development consultancy is going well with several new web app prototypes/platforms released in the last few months, a new plugin (Social Gallery for WordPress) is being well received (and even imitated already!) and amongst all that ChooseFest has had some interesting developments. Also I am now [&#8230;]</p>
<p>The post <a href="https://blog.woodylabs.com/2012/09/hotmail-and-character-sets-make-sure-your-emails-get-there/">Hotmail and Character Sets: Make Sure Your Emails Get There</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p><hr /><a href="https://blog.woodylabs.com">Visit Woody Haydays Blog</a><hr />]]></description>
										<content:encoded><![CDATA[<p>It&#8217;s been a hectic few months &#8211; the <a href="http://www.stormgate.co.uk/blog/web-developer-for-hire/">web development consultancy</a> is going well with several new web app prototypes/platforms released in the last few months, a new plugin (<a href="http://www.socialgalleryplugin.com">Social Gallery for WordPress</a>) is being well received (and even imitated already!) and amongst all that <a href="http://www.choosefest.com">ChooseFest</a> has had some interesting developments. Also I am now a year older. Anyway enough with the stereotypical excuses for lack of blogging, here&#8217;s a snippet-size-little blog post with a little should-of-been-obvious fix for sending emails out of php in interesting character sets e.g. Japanese, sometimes its the most ridiculously simple stuff that catches you out!</p>
<p style="text-align: left;">Traditional and SMTP emails out of php&#8217;s main mail() function will often be ignored, it seems, by Hotmail (and sometimes yahoo) if the email contains character without specific mention of the correct character set. It&#8217;s irritating as every other carrier seems to just deal with it but Hotmail (and sometimes yahoo) just act like no email ever existed, there&#8217;s no bounce-back, no spam folder message &#8211; just nothing.</p>
<p style="text-align: center;"><img decoding="async" class="aligncenter  wp-image-918" title="Are your web app emails getting to their end destination? Blocked by Hotmail?" src="https://blog.woodylabs.com/wp-content/uploads/2012/09/hotmail-blocking-emails.jpg" alt="" width="162" height="100" /><span id="more-916"></span></p>
<p>In any case, set the header of your email to contain the character set, and if the email your sending is html then make sure you include that in the email body meta, seems obvious but is annoyingly easy to forget.</p>
<p>e.g. Add this line to whatever headers you are using:</p>
<pre class="brush: php; title: ; notranslate">$headers .= &quot;Content-Type: text/html; charset=UTF-8\r\n&quot;;</pre><p>The post <a href="https://blog.woodylabs.com/2012/09/hotmail-and-character-sets-make-sure-your-emails-get-there/">Hotmail and Character Sets: Make Sure Your Emails Get There</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>IP to Location Alternative: Javascript &#8211; Using JS to find Browser Country / Location not from IP</title>
		<link>https://blog.woodylabs.com/2011/12/ip-to-location-alternative-javascript-using-js-to-find-browser-country-location-not-from-ip/</link>
		
		<dc:creator><![CDATA[Woody]]></dc:creator>
		<pubDate>Fri, 02 Dec 2011 09:04:41 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[explorations]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[location]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[timezones]]></category>
		<guid isPermaLink="false">http://blog.woodylabs.com/?p=821</guid>

					<description><![CDATA[<p>Know your audience? Got google analytics aggregating their details? Great, good for you! But doe&#8217;s that add any value in the short term? Improve THEIR browsing experience? In the long run you should use analytics to achieve better sites (although many don&#8217;t) &#8211; but for now, right here you can still add some of the [&#8230;]</p>
<p>The post <a href="https://blog.woodylabs.com/2011/12/ip-to-location-alternative-javascript-using-js-to-find-browser-country-location-not-from-ip/">IP to Location Alternative: Javascript – Using JS to find Browser Country / Location not from IP</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p><hr /><a href="https://blog.woodylabs.com">Visit Woody Haydays Blog</a><hr />]]></description>
										<content:encoded><![CDATA[<p>Know your audience? Got google analytics aggregating their details? Great, good for you! But doe&#8217;s that add any value in the short term? Improve THEIR browsing experience? In the long run you should use analytics to achieve better sites (although many don&#8217;t) &#8211; but for now, right here you can still add some of the future frill. Take this situation: You want to show different content/additional content to each nationalities (maybe aim for a few &#8211; US, UK, AUS) &#8211; Did you know that adding a national flag that a user can associate with may increase sales up to 20%, or More? Go read Ca$hvertising. In any case if your sitting comfortably, take a look below for the how to!</p>
<div align="center"><img fetchpriority="high" decoding="async" src="http://farm1.staticflickr.com/122/303184034_9ac842c4e1.jpg" width="500" height="358" alt="Mars Landers on Map"><br />
Javascript &#8211; Using JS to find Browser Country / Location not from IP <a href="http://www.flickr.com/photos/toasty/303184034/" title="Mars Landers on Map by ToastyKen, on Flickr" rel="nofollow" target="_blank" style="font-size:10px">Photo by ToastyKen</a>
</div>
<p><span id="more-821"></span></p>
<h4>Common solutions to identifying a users locale/localizing/localising a web client:</h4>
<p>Using PHP / ASP.NET take the users IP and feed into an ip to location service (geo ip) to find a country from ip.<br />
<strong>Pro&#8217;s:</strong> Server-side off the bat, can cache a database of IP&#8217;s (although would you?)<br />
<strong>Con&#8217;s:</strong> Adds another 2 hops to at least initial page load, IP location service&#8217;s can cost or be faulty</p>
<p>Using the request headers (again server-side) to identify an &#8220;accepted language&#8221; and then guestimating their location (taking en-US&#8230;for example.)<br />
<strong>Pro&#8217;s:</strong> Server-side to start with, no extra hops/calls required, this data is already available whether you use it or not, more useful for language (although limited)<br />
<strong>Con&#8217;s:</strong> Unreliable &#8211; mostly because of a few of the BIG browsers default to en-US for all english users, often international users might learn to use a browser in English anyway &#8211; defeating the point</p>
<h4>Another solution (work in progress:)</h4>
<p>A step towards a proper solution, and in my case a solution for MY original problem, is to at least work out their TIMEZONE. What? I hear you say, why the timezone? Well if you know, for example using analytics data, that your user base is 40% US, 50% UK and 10% rest of the world you can at least make a START by dealing with the two major constituents of your audience. I can envisage A more complete solution though, by combining the use of request headers accepted language AND the following Javascript timezone detection:</p>
<p>Searching around a bit I found <a href="http://unmissabletokyo.com/country-detector.html" target="_blank" rel="nofollow">this</a> which showed a lot of promise. This javascript works out the users Operating System time offset, and from that you can define which timezone they are in. Useful, if like me you know your users in a specific timezone are likely to be in one country, not particularly if they are possibly in multiple countries within a timezone. </p>
<h4>A solution / exploration &#8211; location detection in javascript</h4>
<p>The following Javascript gives you both indicators, using navigator.language/systemlanguage it detects the browser&#8217;s language, and then using an expanded upon version of the above script it will provide you with the possible countries from the users OS timezone offset. How useful this is to you is depending on the application, but check it out &#8211; build some fantastic solution off of it, then show me, because I probably won&#8217;t get round to it!</p>
<pre class="brush: jscript; title: ; notranslate">
var langCode = navigator.language || navigator.systemLanguage;
var lang = langCode.toLowerCase(); lang = lang.substr(0,2);

var dateObject = new Date(); //this timezone offset calc taken from http://unmissabletokyo.com/country-detector.html
var timeOffset = - dateObject.getTimezoneOffset() / 60; 
var c = &quot;&quot;; //this will ultimately end up as a country/csv of possible countries
switch (timeOffset) { //I expanded upon this switch, adding all the possible countries
	case 0: 
	 c = 'Algeria, Ascension Island, Burkina Faso, Faeroe Islands, Ghana, Guinea Republic, Iceland, Ireland, Ivory Coast, Liberia, Mali, Morocco, Sao Tome &amp; Principe, Senegal, Sierra Leone, St Helena, The Gambia, Togo, United Kingdom'; break;
	
	case 1: 
	 c = 'Albania, Andorra, Angola, Australia, Austria, Belgium, Benin, Bosnia, Cameroon, Central Africa Republic, Chad, Congo, Croatia, Czech Republic, Democratic Republic of Congo (Zaire), Denmark, Equatorial Guinea, France, Gabon, Germany, Gibraltar, Guam, Hungary, Italy, Liechtenstein, Luxembourg, Macedonia (Fyrom), Malta, Mariana Islands, Marshall Islands, Micronesia, Monaco, Netherlands, Niger, Nigeria, Norway, Papua New Guinea, Poland, Portugal, San Marino, Serbia, Slovak Republic, Slovenia, Spain, Sweden, Switzerland, Tunisia'; break;
	 
	case -1: 
	 c = 'Cape Verde Islands, Cook Islands, French Polynesia, Guinea Bissau, USA'; break;
	 
	case 11:	
	 c = 'New Caledonia, Solomon Islands, Vanuatu'; break;
	 
	case -11:
	 c = 'Niue Island, Samoa (American), Samoa (Western), USA'; break;
	 
	case 11.5:
	 c = 'Norfolk Island'; break;
	 
	case 12:	
	 c = 'Fiji Islands, Kiribati, Nauru, New Zealand, Tuvalu, Wallis &amp; Futuna Islands'; break;
	 
	case 13:
	 c = 'Tonga'; break;
	 
	case 2:	
	 c = 'Botswana, Bulgaria, Burundi, Cyprus, Democratic Republic of Congo (Zaire), Egypt, Finland, Greece, Israel, Jordan, Lebanon, Lesotho, Libya, Lithuania, Malawi, Mozambique, Namibia, Palestine, Romania, Rwanda, South Africa, Sudan, Swaziland, Syria, Turkey, Zambia, Zimbabwe'; break;
	 
	case 3:
	 c = 'Bahrain, Belarus, Comoros Island, Djibouti, Eritrea, Estonia, Ethiopia, Iraq, Kenya, Kuwait, latvia, Madagascar, Mayotte Islands, Moldova, Qatar, Russia, Saudi Arabia, Somalia, Tanzania, Uganda, Ukraine, Yemen Arab Republic'; break;
	 
	case -3:
	 c = 'Argentina, Brazil, Cuba, Greenland, Guyana, Uruguay'; break;
	
	case 3.5:
	 c = 'Iran'; break;
	
	case -3.5:
	 c = 'Surinam'; break;
	
	case 4:
	 c = 'Armenia, Azerbaijan, Georgia, Mauritius, Oman, Reunion Island, Seychelles, United Arab Emirates'; break;
	
	case -4:
	 c = 'Anguilla, Antigua and Barbuda, Aruba, Barbados, Bermuda, Bolivia, Brazil, Canada, Chile, Dominica Islands, Dominican Republic, Falkland Islands, French Guiana , Grenada, Guadeloupe, Martinique, Montserrat, Netherlands Antilles, Paraguay, Puerto Rico, St Kitts &amp; Nevia, St Lucia, Trinidad &amp; Tobago, Venezuela'; break;
	
	case 5:
	 c = 'Diego Garcia, Maldives Republic, Pakistan, Turkmenistan'; break;
	
	case -5:
	 c = 'Bahamas, Brazil, Canada, Cayman Islands, Columbia, Ecuador, Haiti, Jamaica, Panama, Peru, Turks &amp; Caicos Islands, USA'; break;
	
	case 5.5:
	 c = 'Bhutan,India,Nepal,Sri Lanka'; break;
	
	case 6:
	 c = 'Bangladesh, Kazakhstan, Kyrgyzstan, Tajikistan, Uzbekistan'; break;
	
	case -6:
	 c = 'Belize, Canada, Costa Rica, El Salvador, Guatemala, Honduras, Mexico, Nicaragua, USA'; break;
	
	case 6.5:
	 c = 'Myanmar (Burma)'; break;
	
	case 7:
	 c = 'Australia, Cambodia, Indonesia, Laos, Thailand, Vietnam'; break;
	
	case -7:
	 c = 'Canada, Mexico, USA'; break;
	
	case 8:
	 c = 'Australia, Brunei, China, Hong Kong, Indonesia, Macau, Malaysia, Mongolia, Philippines, Singapore, Taiwan'; break;
	
	case -8:
	 c = 'Canada, Mexico, USA'; break;
	
	case 9:
	 c = 'Australia, Indonesia, Japan, Korea, North, Korea, South, Palau'; break;
	
	case -9:
	 c = 'USA'; break;
}

//at this point Lang should be a 2 letter language code (e.g. en), timeOffset will be the users hour offset from GMT and c will be the csv of possible countries!
alert('Lang: ' + lang + &quot;\r\n&quot; + 'timeOffset: ' + timeOffset + &quot;\r\n&quot; + 'Possible Countries: ' + &quot;\r\n&quot; + c);
</pre>
<p>You can get the full source for this zipped <a href="https://blog.woodylabs.com/downloads/javascript.timezone.country-detection.zip">here</a>, included is a minified version wrapped in a function, isn&#8217;t that nice of me? Use it as you will, and if you create something epic, show me!</p>
<p><strong>Countries/timezones:</strong> I built the timezone offset switch based on the wikipedia list of countries and their timezones, so its comprehensive.</p><p>The post <a href="https://blog.woodylabs.com/2011/12/ip-to-location-alternative-javascript-using-js-to-find-browser-country-location-not-from-ip/">IP to Location Alternative: Javascript – Using JS to find Browser Country / Location not from IP</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
