PHP | IntlChar::isdigit()函数

这个 IntlChar::isdigit() 函数是PHP中的一个内置函数,用于确定给定的输入代码数据是否为数字字符。当字符位于普通类别十进制数字下时,返回true。从Unicode 4开始,这与测试十进制的数字类型相同。

null

语法:

bool IntlChar::isdigit ( $codepoint )

参数: 此函数接受一个参数,如上所述,如下所述:

  • $codepoint: 输入参数$input_codepoint是一个整数或字符,编码为 UTF-8 一串

返回值: 如果$codepoint数据是数字字符,则返回True,否则返回False。 例如:

Input : $codepoint = "X"Output : bool(false)Input : $codepoint = "7"Output : bool(true)

下面的程序说明了 IntlChar::isdigit() PHP中的函数: 项目1:

php

<?php
// PHP code to illustrate the
// IntlChar::isdigit() function.
// single digit
var_dump(IntlChar::isdigit( "5" ));
// number cases
var_dump(IntlChar::isdigit( "5555" ));
// float number
var_dump(IntlChar::isdigit( "15.08" ));
// big number
var_dump(IntlChar::isdigit( "12e" ));
?>


输出:

bool(true)NULL NULL NULL

项目2:

php

<?php
// PHP code to illustrate the
// IntlChar::isdigit() function.
// alphabet cases
var_dump(IntlChar::isdigit( "G" ));
// in space cases
var_dump(IntlChar::isdigit( " " ));
// new line cases
var_dump(IntlChar::isdigit( "" ));
// string cases
var_dump(IntlChar::isdigit( "Geeks " ));
// symbol cases
var_dump(IntlChar::isdigit( "@" ));
?>


输出:

bool(false) bool(false) bool(false) NULL bool(false)

方案3:

php

<?php
// PHP code to illustrate the
// IntlChar::isdigit() function.
var_dump(IntlChar::isdigit( "0" ));
var_dump(IntlChar::isdigit( ' ' ));
?>


输出:

bool(true) bool(false)

参考资料: http://php.net/manual/en/intlchar.isdigit.php

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