#7 - Email obfuscation
Data: 2018-05-05 12:00 - PHP
Simple email obfuscation to prevent scrapping by bots.
<?php
function obfuscate_email($email) {
$fn = 'this.href=\'mailto:\'+atob(this.dataset.e.split(\'\').reverse().join(\'\'));this.removeAttribute(\'onmouseenter\');this.removeAttribute(\'onfocus\')';
$email_obf_tokens = implode('<span style="display: none;">spam</span>', preg_split('/(@|[.])/', $email, -1, PREG_SPLIT_DELIM_CAPTURE));
echo '<a href="#" data-e="', strrev(base64_encode($email)), '" onmouseenter="', $fn, '" onfocus="', $fn, '">', $email_obf_tokens, '</a>';
}
echo obfuscate_email('email@example.com');