Simple PHP Email Obfuscation

Sep
15

Here’s a simple piece of code that performs PHP based email obfuscation to replace standard characters with an ASCII encoded alternative.

This technique, although simple, will block some of the less intelligent spiders/robots out there. There are many other techniques including using JavaScript to render email address or images or even reversing the email address through CSS, however they all have their pros and cons and remember there isn’t an solution.

<?php

function email_obfuscator( $email )
{
$strArray = str_split( $email );
$obfEmail = '';

foreach( $strArray as $char )
{
$obfEmail .= '&#'.ord( $char );
}

return $obfEmail ;
}

echo '<a href="mailto:'.email_obfuscator('test@test.com').'">'.email_obfuscator('test@test.com').'</a>';

?>

8 Responses to “Simple PHP Email Obfuscation”

  1. Wow, thanks didn’t know about this one!

  2. hi
    nc7sk95nq1odnmyt
    good luck

  3. It’s very good article. Great site with very good look and perfect information. I like it too.

  4. It’s very good article. Great site with very good look and perfect information. I like it too.

  5. very nice sites thanks admin…..

  6. legrand says:

    It’s very good article. Great site with very good look and perfect information. I like it too

  7. It’s very good article. Great site with very good look and perfect information. I like it too

  8. güvenlik kameraları,kamera,sistemleri,kayıt cihazı,dvr kart,fiyatları,alarm sistemi

Leave a Reply