[ create a new paste ] login | about

Link: http://codepad.org/UIrhI5ep    [ raw code | output | fork ]

aeiou - PHP, pasted on Sep 17:
<?php

$valid = array
(
	'l3tt3rsAndNumb3rs@domain.com',
	'has-dash@domain.com',
	'hasApostrophe.o\'leary@domain.org',
	'uncommonTLD@domain.museum',
	'uncommonTLD@domain.travel',
	'uncommonTLD@domain.mobi',
	'countryCodeTLD@domain.uk',
	'countryCodeTLD@domain.rw',
	'lettersInDomain@911.com',
	'underscore_inLocal@domain.net',
	'IPInsteadOfDomain@127.0.0.1',
	'IPAndPort@127.0.0.1:25',
	'subdomain@sub.domain.com',
	'local@dash-inDomain.com',
	'dot.inLocal@foo.com',
	'a@singleLetterLocal.org',
	'singleLetterDomain@x.org',
	'&*=?^+{}\'~@validCharsInLocal.net',
);

$invalid = array
(
	'missingDomain@.com',
	'@missingLocal.org',
	'missingatSign.net',
	'missingDot@com',
	'two@@signs.com',
	'colonButNoPort@127.0.0.1:',
	'someone-else@127.0.0.1.26',
	'.localStartsWithDot@domain.com',
	'localEndsWithDot.@domain.com',
	'two..consecutiveDots@domain.com',
	'domainStartsWithDash@-domain.com',
	'domainEndsWithDash@domain-.com',
	'TLDDoesntExist@domain.moc',
	'numbersInTLD@domain.c0m',
	'missingTLD@domain.',
	'! "#$%(),/;<>[]`|@invalidCharsInLocal.org',
	'invalidCharsInDomain@! "#$%(),/;<>_[]`|.org',
	'local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org'
);

function valid($email)
{
   echo filter_var($email, FILTER_VALIDATE_EMAIL) !== FALSE ? '  Valid' : 'Invalid',"\t\t{$email}\n";
}

echo "Should be valid\n====================\n";
array_walk($valid, 'valid');
    

echo "\n\nShould be invalid\n====================\n";
array_walk($invalid, 'valid');


Output:
Should be valid
====================
  Valid		l3tt3rsAndNumb3rs@domain.com
  Valid		has-dash@domain.com
  Valid		hasApostrophe.o'leary@domain.org
  Valid		uncommonTLD@domain.museum
  Valid		uncommonTLD@domain.travel
  Valid		uncommonTLD@domain.mobi
  Valid		countryCodeTLD@domain.uk
  Valid		countryCodeTLD@domain.rw
  Valid		lettersInDomain@911.com
  Valid		underscore_inLocal@domain.net
  Valid		IPInsteadOfDomain@127.0.0.1
Invalid		IPAndPort@127.0.0.1:25
  Valid		subdomain@sub.domain.com
  Valid		local@dash-inDomain.com
  Valid		dot.inLocal@foo.com
  Valid		a@singleLetterLocal.org
  Valid		singleLetterDomain@x.org
Invalid		&*=?^+{}'~@validCharsInLocal.net


Should be invalid
====================
Invalid		missingDomain@.com
Invalid		@missingLocal.org
Invalid		missingatSign.net
Invalid		missingDot@com
Invalid		two@@signs.com
Invalid		colonButNoPort@127.0.0.1:
Invalid		someone-else@127.0.0.1.26
Invalid		.localStartsWithDot@domain.com
Invalid		localEndsWithDot.@domain.com
Invalid		two..consecutiveDots@domain.com
  Valid		domainStartsWithDash@-domain.com
  Valid		domainEndsWithDash@domain-.com
  Valid		TLDDoesntExist@domain.moc
Invalid		numbersInTLD@domain.c0m
Invalid		missingTLD@domain.
Invalid		! "#$%(),/;<>[]`|@invalidCharsInLocal.org
Invalid		invalidCharsInDomain@! "#$%(),/;<>_[]`|.org
  Valid		local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org


Create a new paste based on this one


Comments: