Obfuscate Emails


/ Published in: PHP

A simple PHP function to obfuscate an email address.

Usage:


Copy this code and paste it in your HTML
  1. <?php
  2. /*
  3. A simple PHP function to obfuscate an email address.
  4. By: AJ Batac
  5. URL: http://allanjosephbatac.com
  6.  
  7. Usage:
  8. <?= show_email("[email protected]"); ?>
  9. <?php show_email("[email protected]"); ?>
  10. */
  11.  
  12. function show_email($email)
  13. {
  14. $finished='';
  15. $count = strlen($email);
  16. for($i=0;$i<$count;$i++)
  17. {
  18. $n = rand(0,1);
  19. if($n)
  20. {
  21. $finished.='&#x'.sprintf("%X",ord($email[$i])).';';
  22. }
  23. else
  24. {
  25. $finished.='&#'.ord($email[$i]).';';
  26. }
  27. }
  28. return $finished;
  29. }
  30. ?>

URL: http://allanjosephbatac.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.