IntlChar::charDigitValue()函数是PHP中的内置函数, 用于从十进制数字字符返回十进制数字值。其中常规类别的十进制数字和" Nd"是十进制的Numeric_Type。
语法如下:
int IntlChar::charDigitValue( $codepoint )
参数:该函数接受单个参数$ codepoint这是常识。输入参数是字符或整数值, 编码为UTF-8串。
返回值:If$ codepoint是十进制数字值, 然后返回True, 否则返回-1。
下面的程序说明了IntlChar :: charDigitValue()PHP中的功能。
程序1:
<?php
// PHP code to illustrate IntlChar::charDigitValue
// function
//Input int codepoint value
var_dump(IntlChar::charDigitValue( "\u{2025}" ));
echo "<br>" ;
//Input character codepoint value
var_dump(IntlChar::charDigitValue( "2345" ));
echo "<br>" ;
//Input int codepoint value
var_dump(IntlChar::charDigitValue( "\u{0774}" ));
echo "<br>" ;
//Input int codepoint value
var_dump(IntlChar::charDigitValue( "2" ));
echo "<br>" ;
//Input character codepoint value
var_dump(IntlChar::charDigitValue( "Geeks" ));
echo "<br>" ;
//Input character codepoint value
var_dump(IntlChar::charDigitValue( "\u{0E66}" ));
echo "<br>" ;
//Input Empty codepoint value
var_dump(IntlChar::charDigitValue( " " ));
?>
输出如下:
int(-1)
NULL
int(-1)
int(2)
NULL
int(-1)
int(-1)
程式2:
<?php
// PHP code to illustrate
// IntlChar::charDigitValue() function
// Declare an array $arr
$arr = array ( "^" , "2345" , "6" , "\n" );
// Loop run for every array element
foreach ( $arr as $val ){
// Check each element as code point data
var_dump(IntlChar::charDigitValue( $val ));
echo "<br>" ;
}
?>
输出如下:
int(-1)
NULL
int(6)
int(-1)
相关文章:
- IntlChar :: isalpha()函数
- IntlChar :: isbase()函数
- IntlChar :: isblank()函数
- IntlChar :: iscntrl()函数
参考: http://php.net/manual/en/intlchar.chardigitvalue.php