Wednesday , December 12 2018
Home / PHP / Encode Email Address using php

Encode Email Address using php

With this snippet, you can encode any email address into HTML entities so that spam bots do not find it.

function encode_email($email=’info@domain.com’, $linkText=’Contact Us’, $attrs =’class=”emailencoder”‘ )
{
// remplazar aroba y puntos
$email = str_replace(‘@’, ‘@’, $email);
$email = str_replace(‘.’, ‘.’, $email);
$email = str_split($email, 5);

$linkText = str_replace(‘@’, ‘@’, $linkText);
$linkText = str_replace(‘.’, ‘.’, $linkText);
$linkText = str_split($linkText, 5);

$part1 = ‘‘;
$part4 = ‘
‘;

$encoded = ‘‘;

return $encoded;
}

About admin

Check Also

Resize Images in php

Creating thumbnails of the images is required many a times, this code will be useful ...

Leave a Reply