Obfuscating email addresses

Discussion in 'Programming' started by sarahk, May 31, 2004.

  1. #1
    How do I use php to convert



    to

    echo "<a href='&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#115;&#97;&#114;&#97;&#104;&#64;&#109;&#121;&#115;&#105;&#116;&#101;&#46;&#99;&#111;&#109;'>&#115;&#97;&#114;&#97;&#104;&#64;&#109;&#121;&#115;&#105;&#116;&#101;&#46;&#99;&#111;&#109;</a>";
    
    Code (markup):
    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 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 for the rest?

    Sarah
     
    sarahk, May 31, 2004 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,802
    Likes Received:
    4,534
    Best Answers:
    123
    Trophy Points:
    665
    #2
    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 31, 2004 IP
  3. sarahk

    sarahk iTamer Staff

    Messages:
    28,802
    Likes Received:
    4,534
    Best Answers:
    123
    Trophy Points:
    665
    #3
    sarahk, May 31, 2004 IP
  4. Voyager

    Voyager Guest

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    For more lazy folks (like me), there is always Manas Tungare.
     
    Voyager, May 31, 2004 IP
  5. Owlcroft

    Owlcroft Peon

    Messages:
    645
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    0
    #5
    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?
     
    Owlcroft, Jun 1, 2004 IP
  6. relaxzoolander

    relaxzoolander Peon

    Messages:
    141
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #6
    relaxzoolander, Jun 2, 2004 IP