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.








