Trick to obfuscate email with PHP

Now, it is an era of information. Personal details such name, email etc are so valuable and some coder create they own scraping tool to collect thus data. When we placed email address on website, you may experience spam issues, this because spammer bots havest your email address.

It better to put some prevention for this problem with obfuscated email address. Here some snippet using PHP script :

<?php
     $email = 'mailto:' . 'ayam@ayam.jer';
     $crackme = "";
     for ($i=0; $i<strlen($email); $i++){
         $crackme .= "&#" . ord($email[$i]) . ";";
     }
?>
<a href="<?=$crackme?>">Contact me!</a>

You may see a normal hyperlink html on browser such Contact me! but when you view the HTML source code, you will see:

<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#97;&#121;&#97;&#109;&#64;&#97;&#121;&#97;&#109;&#46;&#106;&#101;&#114;">Contact me!</a>

The trick is to encode the email with ASCII chars entities. You can use mothereffin converter tool to encode the href value from example above.

You can convert the snippet as function by your self so you can be called when needed and much relevent with coding standard. Hopefully this trick can decrease you email spam/junk from spammer :P

Wassalam ~


Actions Speak Louder Than Words!

Powered by Jekyll and Hydejack v7.3.0