本文整理汇总了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('Ž'));
}
示例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;
}
示例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);
}