选择语言 :

 Core_HTML::obfuscate

Generates an obfuscated version of a string. Text passed through this method is less likely to be read by web crawlers and robots, which can be helpful for spam prevention, but can prevent legitimate robots from reading your content.

echo HTML::obfuscate($text);
string Core_HTML::obfuscate( string $string )
since
3.0.3

参数列表

参数 类型 描述 默认值
$string string String to obfuscate
返回值
  • string
File: ./core/classes/html.class.php
public static function obfuscate($string)
{
    $safe = '';
    foreach (str_split($string) as $letter)
    {
        switch (rand(1, 3))
        {
            // HTML entity code
            case 1 :
                $safe .= '&#' . ord($letter) . ';';
                break;
            // Hex character code
            case 2 :
                $safe .= '&#x' . dechex(ord($letter)) . ';';
                break;
            // Raw (no) encoding
            case 3 :
                $safe .= $letter;
        }
    }
    return $safe;
}