function is_valid_email($input) {
preg_match("^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$", $input))
}
The Sourcebench
Here in the sourcebench you can find a variety of little helpers, articles, code snipplets and sometimes even just random thoughts of our community.
Obfuscate e-mail link
- July 23rd, 2007
- No Comments
- php, Snippet-library
This function allows it to hide the email address within a link so it is not this easy to be grabbed by spiders.
function mailto($address, $text)
{
$address_encode = '';
for ($x=0; $x < strlen($address); $x++) {
if(preg_match('!\w!',$address[$x])) {
$address_encode .= '%' . bin2hex($address[$x]);
} else {
$address_encode .= $address[$x];
}
}
$text_encode = '';
for ($x=0; $x < strlen($text); $x++) {
$text_encode .= '' . bin2hex($text[$x]).';';
}
$mailto = "mailto:";
return ''.$text_encode.'';
}
echo mailto('my@mail.com','Mail me');
Community friends:
