经测试代码如下:
/**
* 电子邮件地址编码
*
* @param
* @author 编程之家 jb51.cc jb51.cc
**/
function encode_email($email='info@domain.com',$linkText='Contact Us',$attrs ='class="emailencoder"' )
{
// remplazar aroba y puntos,PHP编码电子邮件地址
$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 = '</a>';
$encoded = '<script type="text/javascript">';
$encoded .= "document.write('$part1');";
$encoded .= "document.write('$part2');";
foreach($email as $e)
{
$encoded .= "document.write('$e');";
}
$encoded .= "document.write('$part3');";
foreach($linkText as $l)
{
$encoded .= "document.write('$l');";
}
$encoded .= "document.write('$part4');";
$encoded .= '</script>';
return $encoded;
}
/*** 代码来自编程之家 jb51.cc(jb51.cc) ***/
原文链接:https://www.f2er.com/php/529083.html