ctype_alnum ( $text );
它检查提供的字符串text中的所有字符是否是字母数字的。在标准的C语言环境中,字母只是[A-Za-z],函数相当于preg_match(‘/^[a-z0-9]+$/ID',$text)。
Sr.No | 参数 & Description |
---|---|
1 |
text(必需) 链接:https://www.learnfk.comhttps://www.learnfk.com/php/php-function-ctype-alnum.html 来源:LearnFk无涯教程网 字符串。 |
如果文本中的每个字符都是字母或数字,则返回TRUE,否则返回FALSE。
<?php $strings=array('hello', 'foo!#$bar'); foreach ($strings as $example) { if (ctype_alnum($example)) { echo "$example consists of all letters or digits.\n"; }else { echo "$example does not have all letters or digits.\n"; } } ?>
这将产生以下输出-
hello consists of all letters or digits. foo!#$bar does not have all letters or digits.
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)