Posted By

gbot on 03/09/08


Tagged

email link encode mailto obfuscate


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

gbot
SpinZ
AlastairDewar


encode mailto: link


 / Published in: PHP
 

  1. <?php
  2. function encode_mailto($mail, $label, $subject = "", $body = "") {
  3. $chars = preg_split("//", $mail, -1, PREG_SPLIT_NO_EMPTY);
  4. $new_mail = "<a href=\"mailto:";
  5. foreach ($chars as $val) {
  6. $new_mail .= "&#".ord($val).";";
  7. }
  8. $new_mail .= ($subject != "" && $body != "") ? "?subject=".$subject."&body=".$body : "";
  9. $new_mail .= "\">".$label."</a>";
  10. return $new_mail;
  11. }
  12. ?>

Report this snippet  

You need to login to post a comment.