Loan Consolidation - Mobile Phones - Loans - Flights - Personal Loans

PDA

View Full Version : Obfuscating email addresses


sarahk
May 31st 2004, 2:55 pm
How do I use php to convert

sarah@mysite.com

to

echo "<a href='mailto:sarah@mysite.com'>sarah@mysite.com</a>";


Actually that's not right: if you view the source you will see that the href is a string of html codes. "m" is written as & # 109 (without the spaces) and so on. The idea is that the idea is that mail harvesters will find it hard to read and move on, not realising that this is an email address.

I've trawled around http://www.php.net (http://www.php.net/) but can't find an obvious solution. I'm guessing that there is a command,

or do I need to hard code the ascii codes for the alphanumeric characters and just use urlencode (http://www.php.net/urlencode) for the rest?

Sarah

sarahk
May 31st 2004, 3:11 pm
found my own answer http://www.php.net/ord :)

there are examples with the code. I don't think ord() is the most intuitive name for a function tho'

sarahk
May 31st 2004, 3:58 pm
if any one is interested the final result is at http://www.pcpropertymanager.com/test/obfuscate.php

Voyager
May 31st 2004, 4:05 pm
For more lazy folks (like me), there is always Manas Tungare (http://www.manastungare.com/asp/preventspam.asp).

Owlcroft
Jun 1st 2004, 11:17 pm
No, "ord" is surely not intuitive. I had to hunt a while, thinking there was no such PHP function, till I finally found it the first time.

"Ordinal", I guess?

relaxzoolander
Jun 2nd 2004, 2:12 am
my web design site (http://www.moshbox.com/index.asp?a=contact) email address solution.

:)