I would say that's the best approach if you're displaying it publicly. Though if registration is present on your website, then also ensure people are registered and logged in before displaying email addresses in any format.
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
The Following User Says Thank You to Wildhoney For This Useful Post:
Figured I would put my 2 cents in, since I actually just did something similar to this for my portfolio. I grabbed my function for a basic string to image, and made some minor changes and comments
<?php /* * Create a Image Base. * Sizes are in pixels(px), though you do not need to include this. * $var = imagecreate(width, height); */ $image = imagecreate(200, 25); /* * Set Image Background Color. * 0=darkest - 255=lightest * imagecolorallocate(source, red, blue, green); */ imagecolorallocate($image, 200, 200, 200); /* * create string color * imagecolorallocate(source, red, blue, green); */ $fontColor = imagecolorallocate($image, 0, 0, 0); /* * Set x-coordinate of the upper left corner of the string */ $startX = 35; //35 px from left /* * Set y-coordinate of the upper left corner of the string */ $startY = 5; //5 px from top /* * Set the string to be used. This is set via GET calls. * ex: image.php?string=YourName@Host.com * Or can be changed here. */ $string = $_GET['string']; /* * Draw a textual string onto your source. * imagestring(source, font-size, X-coord, Y-coord, string, font-color); */ imagestring($image, 3, $startX, $startY, $string, $fontColor); /* * Set document type. * This will be the type of image displayed. * Most common image types: * header("Content-type: image/jpeg"); * header("Content-type: image/gif"); * header("Content-type: image/png"); */ header("Content-type: image/jpeg"); /* * Output your new image. * Depending on header type: * imagejpeg($source); * imagepng($source); * imagegif($source); */ imagejpeg($image); /* * free memory associated with your image. */ imagedestroy($image); ?>
call that like image.php?string=YourName@Host.com in your browser, or in an image tag as your src.
Do some expiramenting with it. Change image sizes, colors, types, etc...
though like Wildhoney said... Its not good to publicly display email addresses. Site crawling bots that harvest emails, and spam them with porn ads... its not fun. The above script could, should, and did have many more security features added to it.
Oh, Where i have my imagestring(), is where you would use the imagefttext($image, $textvar) if you really wanted to. see http://us2.php.net/imagefttext for more details.
"Knowledge is power. Abuse it."~Evulness
My portfolio: www.evularts.com