PHP Validate 42 Emails

From 42Experiment

Jump to: navigation, search

At the time of this writing, PHP's FILTER_VALIDATE_EMAIL does not validate numeric TLDs. A PHP bug report has been submitted.

In the meantime, a quick and dirty hack can be used for .42 domains:

function validEmail($email) { 	
 // PHP doesn't know about the .42 TLD yet, so we replace it with .org for the test
 if(substr($email, -3) == ".42" )
   $email =   substr($email,0,-3).".org" ;
 // Now we can use PHP's internal filter :-) 
 return(filter_var($email, FILTER_VALIDATE_EMAIL)) ; }

This will return the same thing filter_var() would, if it knew about .42

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox