PHP | IntlChar::ord()函数

这个 IntlChar::ord() 函数是PHP中的一个内置函数,用于返回给定字符的Unicode代码点值。

null

语法:

int IntlChar::ord( $character )

参数: 此函数只接受一个参数 $character 这是强制性的。此参数是Unicode字符。 返回值: 它以整数形式返回Unicode代码点值。

下面的程序说明了 IntlChar::ord() PHP中的函数:

项目1:

PHP

<?php
// PHP function to illustrate
// the use of IntlChar::ord()
// Input int codepoint value
var_dump(IntlChar::ord( "4" ));
// Input character codepoint value
var_dump(IntlChar::ord( "B" ));
// Input character codepoint value
var_dump(IntlChar::ord( "b" ));
//Input int codepoint value
var_dump(IntlChar::ord( "2018" ));
// Input character codepoint value
var_dump(IntlChar::ord( "Geeks" ));
// Input symbole codepoint value
var_dump(IntlChar::ord( "@" ));
// Input symbole codepoint value
var_dump(IntlChar::ord( "*" ));
// Input space codepoint value
var_dump(IntlChar::ord( " " ));
?>


输出:

int(52)int(66)int(98)NULLNULLint(64)int(42)int(32)

项目2:

PHP

<?php
// PHP function to illustrate the
// use of IntlChar::ord()
// Declare an array with
// different codepoint value
$arr = array ( "X" ,
"x" ,
"*" ,
"8" ,
"0" ,
" " ,
"&" ,
")" ,
"99" ,
);
// For loop condition to check
// each character through function
foreach ( $arr as $val ) {
// Check each element as code point data
var_dump(IntlChar::ord( $val ));
}
?>


输出:

int(88)int(120)int(42)int(56)int(48)int(32)int(38)int(41)NULL

相关文章:

参考: http://php.net/manual/en/intlchar.ord.php

© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享