- Using this code, any email address can be encoded as an html character entity to prevent it from being collected by spam programs.
- 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 = '< ;a href="ma';
- $part2 = 'ilto:';
- $part3 = '" '. $attrs .' >';
- $part4 = '';
-
- $encoded = '';
-
- return $encoded;
- }
-
Copy code
|