📅  最后修改于: 2023-12-03 15:03:38.928000             🧑  作者: Mango
IntlChar::isalnum()
函数用于判断一个字符是否为字母或数字。该函数支持 Unicode 字符,因此可以识别各种语言文本中的字母和数字。
bool IntlChar::isalnum ( mixed $codepoint )
参数 $codepoint
表示要判断的 Unicode 码位。
如果 $codepoint
表示的字符是字母或数字,则返回 true
,否则返回 false
。
下面是一个使用 IntlChar::isalnum()
函数的示例程序:
<?php
$c1 = 'a';
$c2 = '9';
$c3 = '@';
if (IntlChar::isalnum($c1)) {
echo "$c1 is an alphanumeric character\n";
} else {
echo "$c1 is not an alphanumeric character\n";
}
if (IntlChar::isalnum($c2)) {
echo "$c2 is an alphanumeric character\n";
} else {
echo "$c2 is not an alphanumeric character\n";
}
if (IntlChar::isalnum($c3)) {
echo "$c3 is an alphanumeric character\n";
} else {
echo "$c3 is not an alphanumeric character\n";
}
输出结果为:
a is an alphanumeric character
9 is an alphanumeric character
@ is not an alphanumeric character
$codepoint
参数不是一个有效的 Unicode 码位,则返回 false
。