note 93591 added to function.preg-match

From: Date: Thu, 17 Sep 2009 14:41:52 +0000
Subject: note 93591 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-160781@lists.php.net to get a copy of this message
// A FUNCTION TO TEST FOR A VALID EMAIL ADDRESS, RETURN TRUE OR FALSE function check_valid_email($email) { // IF PHP 5.2 OR ABOVE, WE CAN USE THE FILTER // MAN PAGE: http://us3.php.net/manual/en/intro.filter.php if (strnatcmp(phpversion(),'5.2') >= 0) { if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) return FALSE; } else { $regex = '/^[A-Z0-9_-][A-Z0-9._-]*@([A-Z0-9][A-Z0-9-]*\.)+[A-Z]{2,6}$/i'; if (!preg_match($regex, $email)) return FALSE; } // FILTER or PREG DOES NOT TEST IF THE DOMAIN OF THE EMAIL ADDRESS IS ROUTABLE $domain = explode('@', $email); if ( checkdnsrr($domain[1],"MX") || checkdnsrr($domain[1],"A") ) return TRUE; // EMAIL NOT ROUTABLE return FALSE; } ---- Server IP: 208.69.120.35 Probable Submitter: 74.9.128.130 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- https://master.php.net/note/edit/93591 Del: integrated -- https://master.php.net/note/delete/93591/integrated Del: useless -- https://master.php.net/note/delete/93591/useless Del: bad code -- https://master.php.net/note/delete/93591/bad+code Del: spam -- https://master.php.net/note/delete/93591/spam Del: non-english -- https://master.php.net/note/delete/93591/non-english Del: in docs -- https://master.php.net/note/delete/93591/in+docs Del: other reasons-- https://master.php.net/note/delete/93591 Reject -- https://master.php.net/note/reject/93591 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#160781) next »