1. 首页
  2. WordPress 函数手册

antispambot()

antispambot( string $email_address, int $hex_encoding )

将电子邮件地址字符转换为HTML实体以阻止垃圾邮件机器人程序。
Converts email addresses characters to HTML entities to block spam bots.

目录锚点:#参数#返回#源码#笔记


参数(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&#91;$i&#93;="" )="" .="" ';';="" }="" elseif="" (="" $j="=" 1="" )="" {="" $email_no_spam_address="" .="$email_address&#91;$i&#93;;" }="" elseif="" (="" $j="=" 2="" )="" {="" $email_no_spam_address="" .='%' .="" zeroise(="" dechex(="" ord(="" $email_address&#91;$i&#93;="" )="" ),="" 2="" );="" }="" }="" return="" str_replace(="" '@',="" '@',="" $email_no_spam_address="" );="" }="">
更新版本 源码位置 使用 被使用
0.71 wp-includes/formatting.php:2792 0 1 function

笔记(Notes)

例子

antispambot() 为WP2原创文章,链接:https://www.wp2.cn/functions/antispambot/

发表评论

您的电子邮箱地址不会被公开。