本文整理匯總了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);
}