Hide MailTo:

Started on the old forum in June 2009 · view the original in the archive · old links redirect here

No replies · 554 views · started 17 years ago · 1 min read

blackhowk Senior · 411 posts #1

Use this function to hide an e-mail address from spam-bots on your website. Use this function to convert the e-mail address into Unicode values and add the html tag and optional extra e-mail info like subject and body text.

<?php 
function hide_mailto($mail, $label, $subject = "", $body = "") {
$chars = preg_split("//", $mail, -1, PREG_SPLIT_NO_EMPTY);
$new_mail = "<a href="mailto:";
foreach ($chars as $val) {
$new_mail .= "&#".ord($val).";";
}
$new_mail .= ($subject != "" && $body != "") ? "?subject=".$subject."&body=".$body : "";
$new_mail .= "">".$label."</a>";
return $new_mail;
}
?>

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close