Displaying email addresses

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Displaying email addresses

Post by kkonline »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


is there any function or class that converts you@yourdomain.com into
you [at] yourdomain [dot] com when an actual email is passed to the class/function?

I wrote

Code: Select all

<?php


//initialize spam-off function (embed it inna page) - JavaScript
function mailto($address,$text='',$subject=''){
$address="user@mail.com";
#divide user from host (cut on @)
$data = explode("@","$address");
#a little extra make-up 
$hostitj = ereg_replace("\.", ' <u>[dot]</u> ', $data[1]);
#if no text present, display address, just a little formatted 
if ("$text" == "") { $text = $data[0] . ' <u>[at]</u> ' . $hostitj; }
#write link
echo "<a href=\"" . $data[1] . "','" . $data[0] . "'\">" . $text . "</a>";

}
?>
But it gives no error and no display on the screen


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

A function, no. You can do it pretty easily with str_replace though.

Code: Select all

$emailAddress = "onion@domain.com";
$emailAddressProtected = str_replace(array(".","@"), array(" [dot] "," [at] "), $emailAddress);
User avatar
xpgeek
Forum Contributor
Posts: 146
Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:

Post by xpgeek »

Another thread this some question is here: viewtopic.php?t=73381&highlight=
This question asks very often - try search before creating new thread please.
Post Reply