<?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>Dominic Sayers &#187; php</title>
	<atom:link href="http://blog.dominicsayers.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dominicsayers.com</link>
	<description></description>
	<lastBuildDate>Tue, 31 Aug 2010 09:12:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<atom:link rel='hub' href='http://blog.dominicsayers.com/?pushpress=hub'/>
		<item>
		<title>Email address validation 1.2</title>
		<link>http://blog.dominicsayers.com/2009/02/22/email-address-validation-12/</link>
		<comments>http://blog.dominicsayers.com/2009/02/22/email-address-validation-12/#comments</comments>
		<pubDate>Sun, 22 Feb 2009 15:25:24 +0000</pubDate>
		<dc:creator>Dominic</dc:creator>
				<category><![CDATA[Email address validation]]></category>
		<category><![CDATA[Relevant to my work]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[address]]></category>
		<category><![CDATA[cal henderson]]></category>
		<category><![CDATA[dave child]]></category>
		<category><![CDATA[doug lovell]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[haacked]]></category>
		<category><![CDATA[iamcal]]></category>
		<category><![CDATA[ietf]]></category>
		<category><![CDATA[phil haack]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rfc]]></category>
		<category><![CDATA[rfc2821]]></category>
		<category><![CDATA[rfc2822]]></category>
		<category><![CDATA[rfc3696]]></category>
		<category><![CDATA[rfc822]]></category>
		<category><![CDATA[simon slick]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://blog.dominicsayers.com/?p=399</guid>
		<description><![CDATA[I've also updated my own routine so that it still passes all the tests, of which there are now 158. As always, the full analysis is on my website and the latest version of the source code will always be in Google Code.]]></description>
			<content:encoded><![CDATA[<h4>Quick links: <a href="http://code.google.com/p/isemail/source/browse/#svn/trunk" target="_blank">Source code</a> | <a href="http://www.dominicsayers.com/isemail/" target="_blank">Email address validators head-to-head</a></h4>
<p>I had some very helpful input from Cal Henderson on interpreting RFC 2822. I&#8217;ve included his latest validator in my head-to-head comparison and updated the test suite to reflect the consensus from our discussion.</p>
<p>I&#8217;ve also updated my own routine so that it still passes all the tests, of which there are now 158. As always, the <a href="http://www.dominicsayers.com/isemail/" target="_blank">full analysis</a> is on my website and the <a href="http://code.google.com/p/isemail/source/browse/trunk" target="_blank">latest version of the source code</a> will always be in Google Code.</p>
<p>I would really appreciate it if you find a valid address that fails my validator, or an invalid one that passes, if you would get in touch with me and let me know.</p>
<p>Here are the latest scores:</p>
<p>Dominic Sayers: <strong>100% validated correctly<br />
<span style="font-weight:normal;">Simon Slick: <strong>91</strong><strong>%</strong><br />
Cal Henderson: <strong>84</strong><strong>%<br />
</strong></span></strong>Phil Haack: <strong>80</strong><strong>%<br />
<span style="font-weight:normal;">Dave Child</span><span style="font-weight:normal;">: </span>79</strong><strong>%</strong> </p>
<p><strong><span style="font-weight:normal;">I know Cal is working on IPv6 validation so this may change soon.</span></strong></p>
<h4><strong></strong>RFC nerd notes</h4>
<p>There are two principle changes in this version.</p>
<p>Firstly, I now accept Dave Child and Cal Henderson&#8217;s opinion that a backslash can escape <em>anything</em> in a quoted string local element. However, it must escape something &#8211; it can&#8217;t be at the end of the string.</p>
<p>Secondly, if the string is <em>not</em> quoted then the local element must be a vanilla atom. You can&#8217;t escape individual characters unless the element is surrounded by double quotes.</p>
<p>By &#8220;local element&#8221; I mean a single component of a dot-delimited local part.</p>
<p>I&#8217;ve extracted the raw specification of a valid email address in BNF (<a href="http://en.wiktionary.org/wiki/Backus-Naur_form">Backus-Naur form</a>) from RFC 5322 and put it here: <a href="http://www.dominicsayers.com/isemail/isemail/RFC5322BNF.html">The BNF from RFC 5322 defining parts of a valid email address</a>. If you try to follow this in the RFC you end up going backwards and forwards and getting confused &#8211; it&#8217;s much easier to understand in the way I&#8217;ve laid it out.</p>
<h4>Quick links: <a href="http://code.google.com/p/isemail/source/browse/trunk" target="_blank">Source code</a> | <a href="http://www.dominicsayers.com/isemail/" target="_blank">Email address validators head-to-head</a></h4>
]]></content:encoded>
			<wfw:commentRss>http://blog.dominicsayers.com/2009/02/22/email-address-validation-12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Email address validation 1.0</title>
		<link>http://blog.dominicsayers.com/2009/02/20/email-address-validation-10/</link>
		<comments>http://blog.dominicsayers.com/2009/02/20/email-address-validation-10/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 10:39:14 +0000</pubDate>
		<dc:creator>Dominic</dc:creator>
				<category><![CDATA[Email address validation]]></category>
		<category><![CDATA[Relevant to my work]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[address]]></category>
		<category><![CDATA[cal henderson]]></category>
		<category><![CDATA[dave child]]></category>
		<category><![CDATA[doug lovell]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[haacked]]></category>
		<category><![CDATA[ietf]]></category>
		<category><![CDATA[phil haack]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rfc]]></category>
		<category><![CDATA[rfc2822]]></category>
		<category><![CDATA[rfc3696]]></category>
		<category><![CDATA[rfc822]]></category>
		<category><![CDATA[simon slick]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://blog.dominicsayers.com/?p=384</guid>
		<description><![CDATA[I have now released version 1.0 of my PHP email address validator. This version passes all 139 unit tests in the suite - tests I have collated from RFC 3696 and from articles by Dave Child, Doug Lovell and Phil Haack. Plus some of my own to test the IPv6 address format.]]></description>
			<content:encoded><![CDATA[<h4>Quick links: <a href="http://code.google.com/p/isemail/source/browse/#svn/trunk" target="_blank">Source code</a> | <a href="http://www.dominicsayers.com/isemail/" target="_blank">Email address validators head-to-head</a></h4>
<p>OK, after some correspondence with <a href="http://www.addedbytes.com/blog/email-address-validation-v2/" target="_blank">Dave Child</a> and <a href="http://code.iamcal.com/php/rfc822/" target="_blank">Cal Henderson</a> I have now released version 1.0 of my PHP email address validator.</p>
<p>This version passes all 139 unit tests in the suite &#8211; tests I have collated from <a href="http://www.apps.ietf.org/rfc/rfc3696.html" target="_blank">RFC 3696</a> and from articles by Dave Child, <a href="http://www.linuxjournal.com/article/9585" target="_blank">Doug Lovell</a> and <a href="http://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx" target="_blank">Phil Haack</a> plus some of my own to test the IPv6 address format. The <a href="http://www.dominicsayers.com/isemail/" target="_blank">full analysis</a> is on my website and the <a href="http://code.google.com/p/isemail/source/browse/#svn/trunk" target="_blank">latest version of the source code</a> will always be in Google Code.</p>
<p>I would really appreciate it if you find a valid address that fails my validator, or an invalid one that passes, if you would get in touch with me and let me know.</p>
<p>Here are the scores on the doors:</p>
<p>Dominic Sayers: <strong>100% validated correctly</strong><br />
Simon Slick: <strong>86%</strong><br />
Dave Child: <strong>81%</strong><br />
Phil Haack: <strong>79%</strong><br />
Cal Henderson: <strong>71%</strong></p>
<p>For the RFC nerds, this version now correctly validates the obsolete local form of <em>word *(&#8220;.&#8221; word)</em>. In other words you can regard the local part of the address as a dot-delimited series of elements each of which can be separately quoted. This means that <em>first.&#8221;last&#8221;@example.com</em> is now recognised as a valid address.</p>
<h4>Quick links: <a href="http://code.google.com/p/isemail/source/browse/#svn/trunk" target="_blank">Source code</a> | <a href="http://www.dominicsayers.com/isemail/" target="_blank">Email address validators head-to-head</a></h4>
]]></content:encoded>
			<wfw:commentRss>http://blog.dominicsayers.com/2009/02/20/email-address-validation-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Email validation head-to-head</title>
		<link>http://blog.dominicsayers.com/2009/02/10/email-validation-head-to-head/</link>
		<comments>http://blog.dominicsayers.com/2009/02/10/email-validation-head-to-head/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 12:42:05 +0000</pubDate>
		<dc:creator>Dominic</dc:creator>
				<category><![CDATA[Email address validation]]></category>
		<category><![CDATA[Relevant to my work]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[address]]></category>
		<category><![CDATA[cal henderson]]></category>
		<category><![CDATA[dave child]]></category>
		<category><![CDATA[doug lovell]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[ietf]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rfc]]></category>
		<category><![CDATA[rfc2822]]></category>
		<category><![CDATA[rfc3696]]></category>
		<category><![CDATA[rfc822]]></category>
		<category><![CDATA[simon slick]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://blog.dominicsayers.com/?p=377</guid>
		<description><![CDATA[I've discovered a number of other public-domain functions that attempt to validate the format of an email address. I tried to validate my 124 test cases against these functions with interesting results]]></description>
			<content:encoded><![CDATA[<h4>Quick links: <a href="http://code.google.com/p/isemail/source/browse/#svn/trunk" target="_blank">Source code</a> | <a href="http://www.dominicsayers.com/isemail/" target="_blank">Email address validators head-to-head</a></h4>
<p>I&#8217;ve discovered a number of other public-domain functions that attempt to validate the format of an email address. I tried to validate my 124 test cases against these functions with the results below:</p>
<p><a href="http://code.google.com/p/isemail/source/browse/#svn/trunk" target="_blank">Dominic Sayers</a>: 100% correctly validated<br />
<a href="http://simonslick.com/VEAF/" target="_blank">Simon Slick</a>: 88% <br />
<a href="http://code.google.com/p/php-email-address-validation" target="_blank">Dave Child</a>: 80%<br />
<a href="http://code.iamcal.com/php/rfc822/" target="_blank">Cal Henderson</a>: 72%</p>
<p>Interestingly, all the other functions failed correctly to validate the example addresses given in <a href="http://www.apps.ietf.org/rfc/rfc3696.html#sec-3" target="_blank">RFC3696</a> (Section 3: Restrictions on email addresses).</p>
<p>I couldn&#8217;t include Doug Lovell&#8217;s <a href="http://www.linuxjournal.com/article/9585" target="_blank">function</a> in my tests because the code is copyright All Rights Reserved by Linux Journal (ironically).</p>
<p>Some of the other functions also supply test cases; I&#8217;ve added these to my test suite. More analysis and commentary here: <a href="http://www.dominicsayers.com/isemail/" target="_blank">RFC-compliant email address validator</a>.</p>
<p>In summary, I recommend you use my function if you want totally RFC-compliant address validation.</p>
<h4>Quick links: <a href="http://code.google.com/p/isemail/source/browse/#svn/trunk" target="_blank">Source code</a> | <a href="http://www.dominicsayers.com/isemail/" target="_blank">Email address validators head-to-head</a></h4>
]]></content:encoded>
			<wfw:commentRss>http://blog.dominicsayers.com/2009/02/10/email-validation-head-to-head/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>RFC-compliant email address validator</title>
		<link>http://blog.dominicsayers.com/2009/01/28/rfc-compliant-email-address-validator/</link>
		<comments>http://blog.dominicsayers.com/2009/01/28/rfc-compliant-email-address-validator/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 18:05:51 +0000</pubDate>
		<dc:creator>Dominic</dc:creator>
				<category><![CDATA[Email address validation]]></category>
		<category><![CDATA[Off topic]]></category>
		<category><![CDATA[Relevant to my work]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[address]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[ietf]]></category>
		<category><![CDATA[ipv4]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rfc]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://blog.dominicsayers.com/?p=361</guid>
		<description><![CDATA[I've come up with a function that validates all parts of a given email address, according to RFCs 1123, 2396, 3696, 4291, 4343, 5321 &#38; 5322. I've released it under a license that allows you to use it royalty-free in commercial or non-commercial work,]]></description>
			<content:encoded><![CDATA[<h4>Quick links: <a href="http://code.google.com/p/isemail/source/browse/#svn/trunk" target="_blank">Source code</a> | <a href="http://www.dominicsayers.com/isemail/" target="_blank">Email address validators head-to-head</a></h4>
<p>There&#8217;s a gazillion regular expressions out there that claim to validate an email address. They don&#8217;t. Doug Lovell explains why <a href="http://www.linuxjournal.com/article/9585" target="_blank">here</a>. The function that Doug made for his article is good, but it delegates the validation of the domain part of the address to the DNS servers of the world. This is a good approach but there are three issues with it:</p>
<ol>
<li>The RFCs reluctantly allow you to use an IP address rather than a domain name, so you need to check for that.</li>
<li>The DNS may not be available to your function at the time it needs to check the address (maybe it&#8217;s an intranet application)</li>
<li>There&#8217;s no need to add extra workload to the DNS servers of the world if the address is wrongly formatted in the first place.</li>
</ol>
<p>So I&#8217;ve come up with a PHP function that validates all parts of a given email address, according to RFCs <a href="http://tools.ietf.org/html/rfc1123" target="_blank">1123</a>, <a href="http://tools.ietf.org/html/rfc2396" target="_blank">2396</a>, <a href="http://tools.ietf.org/html/rfc3696#section-3" target="_blank">3696</a>, <a href="http://tools.ietf.org/html/rfc4291#section-2.2" target="_blank">4291</a>, <a href="http://tools.ietf.org/html/rfc4343#section-2.2" target="_blank">4343</a>, <a href="http://tools.ietf.org/html/rfc5321#section-4.1.2" target="_blank">5321 </a>&amp; <a href="http://tools.ietf.org/html/rfc5322#section-3.4.1" target="_blank">5322</a>. I&#8217;ve released it under a license that allows you to use it royalty-free in commercial or non-commercial work, subject to a few conditions (Doug Lovell&#8217;s function is All Rights Reserved by Linux Journal so you can&#8217;t use it for anything).</p>
<p>It&#8217;s almost certainly the first email address validator that correctly lets you put an IPv6 address in for the domain part&#8230;</p>
<p>I&#8217;ve also included a lot of unit tests, including all Doug Lovell&#8217;s examples and all the examples of valid addresses in RFC 3696. You might try running these test past your current email address validator. Prepare for the same nasty surprise I got :-)</p>
<p>The source code is available <a href="http://code.google.com/p/isemail/source/browse/#svn/trunk" target="_blank">here</a>.</p>
<h4>Quick links: <a href="http://code.google.com/p/isemail/source/browse/#svn/trunk" target="_blank">Source code</a> | <a href="http://www.dominicsayers.com/isemail/" target="_blank">Email address validators head-to-head</a></h4>
]]></content:encoded>
			<wfw:commentRss>http://blog.dominicsayers.com/2009/01/28/rfc-compliant-email-address-validator/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Firefox &quot;problem&quot; turns out to be Dominic problem</title>
		<link>http://blog.dominicsayers.com/2008/10/01/firefox-problem-turns-out-to-be-dominic-problem/</link>
		<comments>http://blog.dominicsayers.com/2008/10/01/firefox-problem-turns-out-to-be-dominic-problem/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 11:11:22 +0000</pubDate>
		<dc:creator>Dominic</dc:creator>
				<category><![CDATA[Relevant to my work]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[compatibility]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[dynamic css]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[mime]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://dominicsayers.wordpress.com/?p=325</guid>
		<description><![CDATA[Big thanks to Sig for helping me out with my Firefox CSS issue. He was dead right &#8211; it was a MIME issue that was easily fixed by setting the MIME type to text/css in the header of the dynamic CSS. More details here: Generating Dynamic CSS with PHP I&#8217;ve left the demonstration in place here: Dynamic [...]]]></description>
			<content:encoded><![CDATA[<p>Big thanks to <a href="http://thingamy.typepad.com/" target="_blank">Sig</a> for helping me out with my Firefox CSS issue. He was dead right &#8211; it was a MIME issue that was easily fixed by setting the MIME type to text/css in the header of the dynamic CSS.</p>
<p style="text-align:left;">More details here: <a href="http://www.digital-web.com/articles/generating_dynamic_css_with_php/"><em>Generating Dynamic CSS with PHP</em></a></p>
<p>I&#8217;ve left the demonstration in place here: <a href="http://www.dominicsayers.com/cssmime"><em>Dynamic CSS MIME demonstration</em></a> but adjusted the text to make it clear I was at fault, not the browser.</p>
<p>Why do the other browsers behave differently? Well the CSS was returned to the page within an element of the page&#8217;s header that declared the contents to be text/css so it was fairly easy for a &#8220;smart&#8221; browser to guess my intention. And also quite easy for me to make the fatal assumption that that was enough.</p>
<p>We live and learn. And Firefox is a strict mistress.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dominicsayers.com/2008/10/01/firefox-problem-turns-out-to-be-dominic-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eyebrow-raising Firefox problem</title>
		<link>http://blog.dominicsayers.com/2008/09/24/eyebrow-raising-firefox-problem/</link>
		<comments>http://blog.dominicsayers.com/2008/09/24/eyebrow-raising-firefox-problem/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 13:34:09 +0000</pubDate>
		<dc:creator>Dominic</dc:creator>
				<category><![CDATA[Relevant to my work]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[dynamic css]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[problem]]></category>

		<guid isPermaLink="false">http://dominicsayers.wordpress.com/?p=323</guid>
		<description><![CDATA[I&#8217;ve come across a problem with a website I&#8217;m developing. My nifty code works fine for all browsers except Firefox. Yes, that&#8217;s right &#8211; Firefox fails to render the page as intended but Chrome, Internet Explorer, Safari and Opera all work fine. I&#8217;ve put a demonstration of the problem here. I&#8217;m surprised that Firefox behaves [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve come across a problem with a website I&#8217;m developing. My nifty code works fine for all browsers except Firefox. Yes, that&#8217;s right &#8211; Firefox fails to render the page as intended but Chrome, Internet Explorer, Safari and Opera all work fine.</p>
<p>I&#8217;ve put a demonstration of the problem <a title="Firefox problem" href="http://dev.dominicsayers.com/" target="_blank">here</a>.</p>
<p>I&#8217;m surprised that Firefox behaves so differently from other browsers. We all know which browsers we think are non-standards-compliant. If I&#8217;d been posting this about an Internet Explorer behaviour then I wouldn&#8217;t have expected any surprise or sympathy. But Firefox. I&#8217;m getting cramp in my eyebrows &#8211; they&#8217;ve been permanently raised since I discovered this.</p>
<p>I&#8217;m hoping there&#8217;s a way I can code round the problem. The latest version of Firefox (3.0.2) still exhibits this odd behaviour.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dominicsayers.com/2008/09/24/eyebrow-raising-firefox-problem/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
