The Greatest PHP Email Validator

I was working on a new site and I needed an email validator. I knew I had one written for an older project but forgot to integrate it into the main framework’s SVN. After couple of minutes worth of searching I finally found it:

function valid_email($string)
{
// HAHAHAHHAHAHHAHAAHAAHHAHAHHAHAAH *mad laughter*
return preg_match('/^[^\x00-\x20()<>@,;:\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()
<>@,;:\".[\]\x7f-\xff]+)*\@[^\x00-\x20()<>@,;:\".[\]\x7f-\xff]
+(?:\.[^\x00-\x20()<>@,;:\".[\]\x7f-\xff]+)+$/i',$string);
}

I don’t remember what it’s based on, but I remember it took me hours to understand it after I found it. Oh my… The guy who wrote it is a badass.

Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • del.icio.us
  • digg
  • Fark
  • Furl
  • Reddit
  • Spurl
  • YahooMyWeb

Leave a comment

Please be polite and on topic. Your e-mail will never be published.