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


PHP core_text::utf8ord方法代碼示例

本文整理匯總了PHP中core_text::utf8ord方法的典型用法代碼示例。如果您正苦於以下問題:PHP core_text::utf8ord方法的具體用法?PHP core_text::utf8ord怎麽用?PHP core_text::utf8ord使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在core_text的用法示例。


在下文中一共展示了core_text::utf8ord方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: test_utf8ord

 /**
  * Tests the static utf8ord method.
  */
 public function test_utf8ord()
 {
     $this->assertSame(ord(''), core_text::utf8ord(''));
     $this->assertSame(ord('f'), core_text::utf8ord('f'));
     $this->assertSame(0x3b1, core_text::utf8ord('α'));
     $this->assertSame(0x439, core_text::utf8ord('й'));
     $this->assertSame(0x2fa1f, core_text::utf8ord('𯨟'));
     $this->assertSame(381, core_text::utf8ord('Ž'));
 }
開發者ID:rushi963,項目名稱:moodle,代碼行數:12,代碼來源:text_test.php

示例2: 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 = core_text::strlen($plaintext);
    $obfuscated = '';
    $prevobfuscated = false;
    while ($i < $length) {
        $char = core_text::substr($plaintext, $i, 1);
        $ord = core_text::utf8ord($char);
        $numerical = $ord >= ord('0') && $ord <= ord('9');
        if ($prevobfuscated and $numerical) {
            $obfuscated .= '&#' . $ord . ';';
        } else {
            if (rand(0, 2)) {
                $obfuscated .= '&#' . $ord . ';';
                $prevobfuscated = true;
            } else {
                $obfuscated .= $char;
                $prevobfuscated = false;
            }
        }
        $i++;
    }
    return $obfuscated;
}
開發者ID:MoodleMetaData,項目名稱:MoodleMetaData,代碼行數:32,代碼來源:weblib.php

示例3: yy_advance

 protected function yy_advance()
 {
     if ($this->yy_buffer_index < $this->yy_buffer_read) {
         $char = $this->yy_buffer[$this->yy_buffer_index++];
         return core_text::utf8ord($char);
     }
     if ($this->yy_buffer_start != 0) {
         // Shunt.
         $j = $this->yy_buffer_read - $this->yy_buffer_start;
         $this->yy_buffer = $this->yy_buffer->substring($this->yy_buffer_start, $j);
         $this->yy_buffer_end -= $this->yy_buffer_start;
         $this->yy_buffer_start = 0;
         $this->yy_buffer_read = $j;
         $this->yy_buffer_index = $j;
         $data = fread($this->yy_reader, 8192);
         if ($data === false || !core_text::strlen($data)) {
             return $this->YY_EOF;
         }
         $this->yy_buffer->concatenate($data);
         $this->yy_buffer_read += core_text::strlen($data);
     }
     while ($this->yy_buffer_index >= $this->yy_buffer_read) {
         $data = fread($this->yy_reader, 8192);
         if ($data === false || !core_text::strlen($data)) {
             return $this->YY_EOF;
         }
         $this->yy_buffer->concatenate($data);
         $this->yy_buffer_read += core_text::strlen($data);
     }
     $char = $this->yy_buffer[$this->yy_buffer_index++];
     return core_text::utf8ord($char);
 }
開發者ID:saylordotorg,項目名稱:moodle-qtype_poasquestion,代碼行數:32,代碼來源:jlex.php


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