public static function email($email = null, $errorMsg = null)
    {
        if (!$email) return null;

        // Convert to lowercase and set UTF-8 character encoding
        $email = trim(mb_strtolower(trim($email), "UTF-8"));

        // Validate email address
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            return null;
        }
        // Return email address
        return $email;
    }
public static function email($email = null, $errorMsg = null)
    {
        if (!$email) return null;

        // Convert to lowercase and set UTF-8 character encoding
        $email = trim(mb_strtolower(trim($email), "UTF-8"));

        // Validate email address
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            return null;
        }
        // Return email address
        return $email;
    }
public static function email ( $ email = null , $ errorMsg = null ) { if ( ! $ email ) return null ; // Convert to lowercase and set UTF-8 character encoding $ email = trim ( mb_strtolower ( trim ( $ email ) , "UTF-8" ) ) ; // Validate email address if ( ! filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ) { return null ; } // Return email address return $ email ; }
Validates and returns sanitized email address.

@param null|string $email User's input email address.
@param null|string $errorMsg Optional user's error message for invalid email address.
@return string
Validates and returns sanitized email address .