Posted By

ajbatac on 03/10/11


Tagged

email safe protect address obfuscate emails


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

uberdragon


Obfuscate Emails


 / Published in: PHP
 

URL: http://allanjosephbatac.com

A simple PHP function to obfuscate an email address.

Usage: <?=> <?php>

  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. ?>

Report this snippet  

You need to login to post a comment.