28th April 2008 - 3 minutes read time
Hiding your email address in an image is the best way of encrypting your email, but if your server doesn't support the GD2 library, or if you don't want to use it, then you might want to look at a different way of doing this.
The easiest way to encrypt your email address is to turn every character into the ASCII code equivalent and use this to display the text in HTML by putting a &# in front of each character. Here is a function that takes a string and turns it into HTML encoded text.
function maskEmail($email) {
$hiddenEmail = '';
$length = strlen($email);
for ($i = 0;$i < $length; $i++) {
$hiddenEmail .= "&#".ord($email[$i]).";";
}
return $hiddenEmail;
}
To use this just feed an email address into it.