/ Published in: PHP
With this snippet, you can encode any email address into HTML entities so that spam bots do not find it.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function encode_email($email='[email protected]', $linkText='Contact Us', $attrs ='class="emailencoder"' ) { // remplazar aroba y puntos $part1 = '<a href="ma'; $part2 = 'ilto:'; $part3 = '" '. $attrs .' >'; $part4 = '</a>'; $encoded = '<script type="text/javascript">'; $encoded .= "document.write('$part1');"; $encoded .= "document.write('$part2');"; foreach($email as $e) { $encoded .= "document.write('$e');"; } $encoded .= "document.write('$part3');"; foreach($linkText as $l) { $encoded .= "document.write('$l');"; } $encoded .= "document.write('$part4');"; $encoded .= '</script>'; return $encoded; }