本文整理汇总了PHP中textlib::utf8ord方法的典型用法代码示例。如果您正苦于以下问题:PHP textlib::utf8ord方法的具体用法?PHP textlib::utf8ord怎么用?PHP textlib::utf8ord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类textlib
的用法示例。
在下文中一共展示了textlib::utf8ord方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: obfuscate_text
/**
* This function takes some text and replaces about half of the characters
* with HTML entity equivalents. Return string is obviously longer.
*
* @param string $plaintext The text to be obfuscated
* @return string The obfuscated text
*/
function obfuscate_text($plaintext)
{
$i = 0;
$length = textlib::strlen($plaintext);
$obfuscated = '';
$prev_obfuscated = false;
while ($i < $length) {
$char = textlib::substr($plaintext, $i, 1);
$ord = textlib::utf8ord($char);
$numerical = $ord >= ord('0') && $ord <= ord('9');
if ($prev_obfuscated and $numerical) {
$obfuscated .= '&#' . $ord . ';';
} else {
if (rand(0, 2)) {
$obfuscated .= '&#' . $ord . ';';
$prev_obfuscated = true;
} else {
$obfuscated .= $char;
$prev_obfuscated = false;
}
}
$i++;
}
return $obfuscated;
}
示例2: test_utf8ord
/**
* Tests the static utf8ord method
* @return void
*/
public function test_utf8ord()
{
$this->assertSame(textlib::utf8ord(''), ord(''));
$this->assertSame(textlib::utf8ord('f'), ord('f'));
$this->assertSame(textlib::utf8ord('α'), 0x3b1);
$this->assertSame(textlib::utf8ord('й'), 0x439);
$this->assertSame(textlib::utf8ord(''), 0x2fa1f);
$this->assertSame(textlib::utf8ord('Ž'), 381);
}
示例3: test_utf8ord
/**
* Tests the static utf8ord method
* @return void
*/
public function test_utf8ord() {
$this->assertSame(textlib::utf8ord(''), ord(''));
$this->assertSame(textlib::utf8ord('f'), ord('f'));
$this->assertSame(textlib::utf8ord('α'), 0x03B1);
$this->assertSame(textlib::utf8ord('й'), 0x0439);
$this->assertSame(textlib::utf8ord(''), 0x2FA1F);
$this->assertSame(textlib::utf8ord('Ž'), 381);
}