ctype_digit ( $text );
它检查提供的字符串text中的所有字符是否都是数字的。它只检查1.9
Sr.No | Parameter & Description |
---|---|
1 |
text(必需) 匹配字符串。 |
如果文本中的每个字符都是十进制数字,则返回TRUE,否则返回FALSE。
链接:https://www.learnfk.comhttps://www.learnfk.com/php/php-function-ctype-digit.html
来源:LearnFk无涯教程网
<?php $strings=array('122.50', '1004', 'foo!#$bar'); foreach ($strings as $test) { if (ctype_digit($test)) { echo "$test consists of all digits.\n"; }else { echo "$test does not have all digits.\n"; } } ?>
这将产生以下结果-
122.50 does not have all digits 1004 consists of all digits foo!#$bar does not have all digits
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)