antispambot


antispambot ( $email_address, $hex_encoding = 0 )

Parameters:
  • (string) email_address Email address.
  • (int) hex_encoding Optional. Set to 1 to enable hex encoding.
Returns:
  • (string) Converted email address.
Defined at:
Change Log:
  • 7: .

Description

Obscures email addresses in HTML to prevent spam bots from harvesting them.Typically this will randomly replace characters from the email address with HTML character references; however, when the hex encoding parameter is set, some characters will also be represented in their percent-encoded form. Because this function is randomized, the outputs for any given input may differ between calls. This helps diversify the ways the email addresses are obscured. When non-UTF-8 inputs are provided, any spans of invalid UTF-8 bytes will be passed through without any obfuscation. Example: $email = 'noreply@example.com'; $obscured = antispambot( $email ); $obscured === 'noreply@example.com'; // Hex-encoding also obscures characters with percent-encoding. $obscured = antispambot( $email, 1 ); $obscured === '%6eore%70l%79@%65x%61mple%2e%63%6fm'; // Non-UTF-8 characters are not obfuscated. "\xFC" is Latin1 "ü". $obscured = antispambot( "b\xFCcher@library.de" ); $obscured === 'b�cher@library.de'; $obscured === "b\xFCcher@library.de"

Related Functions

sanitize_post, is_month, unstick_post, grant_super_admin, is_robots

Top Google Results

User discussions

wpseek mobile