當前位置: 首頁>>代碼示例>>PHP>>正文


PHP textlib::utf8ord方法代碼示例

本文整理匯總了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;
}
開發者ID:masaterutakeno,項目名稱:MoodleMobile,代碼行數:32,代碼來源:weblib.php

示例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);
 }
開發者ID:masaterutakeno,項目名稱:MoodleMobile,代碼行數:13,代碼來源:textlib_test.php

示例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);
 }
開發者ID:Jtgadbois,項目名稱:Pedadida,代碼行數:12,代碼來源:textlib_test.php


注:本文中的textlib::utf8ord方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。