antispambot()函数是Wordpress函数,将电子邮件地址字符转换为HTML实体以阻止垃圾邮件机器人程序。
antispambot( string $email_address, int $hex_encoding )
参数(Parameters)
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
$email_address | (string) | 必需 | 电子邮件地址。 |
$hex_encoding | (int) | 可选 | 设置为1以启用十六进制编码。 |
返回(Return)
(string)转换的电子邮件地址。
源码(Source)
/**
* Converts email addresses characters to HTML entities to block spam bots.
*
* @since 0.71
*
* @param string $email_address Email address.
* @param int $hex_encoding Optional. Set to 1 to enable hex encoding.
* @return string Converted email address.
*/
function antispambot( $email_address, $hex_encoding = 0 ) {
$email_no_spam_address = '';
for ( $i = 0, $len = strlen( $email_address ); $i < $len;="" $i++="" )="" {="" $j="rand(" 0,="" 1="" +="" $hex_encoding="" );="" if="" (="" $j="=" 0="" )="" {="" $email_no_spam_address="" .='&#' .="" ord(="" $email_address[$i]="" )="" .="" ';';="" }="" elseif="" (="" $j="=" 1="" )="" {="" $email_no_spam_address="" .="$email_address[$i];" }="" elseif="" (="" $j="=" 2="" )="" {="" $email_no_spam_address="" .='%' .="" zeroise(="" dechex(="" ord(="" $email_address[$i]="" )="" ),="" 2="" );="" }="" }="" return="" str_replace(="" '@',="" '@',="" $email_no_spam_address="" );="" }="">
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
0.71 | wp-includes/formatting.php:2792 | 0 | 1 function |
笔记(Notes)
例子