PHP code example of choval / email_parse
1. Go to this page and download the library: Download choval/email_parse library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
choval / email_parse example snippets
$parts = email_parse('[email protected] ');
var_dump($parts);
/*
array(11) {
["raw"]=>
string(16) "[email protected] "
["unicode"]=>
bool(false)
["valid"]=>
bool(true)
["idn_domain"]=>
string(11) "example.com"
["idn_local"]=>
string(4) "user"
["idn_tld"]=>
string(3) "com"
["domain"]=>
string(11) "example.com"
["tld"]=>
string(3) "com"
["local"]=>
string(4) "user"
["safe_email"]=>
string(16) "[email protected] "
["email"]=>
string(16) "[email protected] "
}
*/
// Go crazy
$parts = email_parse('π@ν
μ€νΈγγγΉγ');
var_dump($parts);
/*
array(11) {
["raw"]=>
string(26) "π@ν
μ€νΈγγγΉγ"
["unicode"]=>
bool(true)
["valid"]=>
bool(true)
["idn_domain"]=>
string(25) "xn--9t4b11yi5a.xn--zckzah"
["idn_local"]=>
string(8) "xn--h28h"
["idn_tld"]=>
string(10) "xn--zckzah"
["domain"]=>
string(19) "ν
μ€νΈ.γγΉγ"
["tld"]=>
string(9) "γγΉγ"
["local"]=>
string(4) "π"
["safe_email"]=>
string(34) "[email protected] "
["email"]=>
string(24) "π@ν
μ€νΈ.γγΉγ"
}
*/
$valid = email_valid('π@ν
μ€νΈγγγΉγ');
var_dump($valid);
// string(24) "π@ν
μ€νΈ.γγΉγ"
// Non valid because of starting dot
$valid = email_valid('.π@ν
μ€νΈ.γγΉγ');
var_dump($valid);
// bool(false)
$valid = email_safe('π@ν
μ€νΈγγγΉγ');
var_dump($valid);
// string(34) "[email protected] "
// Non valid because of starting dot
$valid = email_safe('.π@ν
μ€νΈ.γγΉγ');
var_dump($valid);
// bool(false)