PHP 中的 ctype_alnum()函数

首页 / PHP入门教程 / PHP 中的 ctype_alnum()函数

ctype_alnum() - 语法

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无涯教程网

字符串。

无涯教程网

ctype_alnum() - 返回值

如果文本中的每个字符都是字母或数字,则返回TRUE,否则返回FALSE。

ctype_alnum() - 示例

<?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.

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

大规模数据处理实战 -〔蔡元楠〕

小马哥讲Spring核心编程思想 -〔小马哥〕

.NET Core开发实战 -〔肖伟宇〕

图解 Google V8 -〔李兵〕

SRE实战手册 -〔赵成〕

Selenium自动化测试实战 -〔郭宏志〕

跟着高手学复盘 -〔张鹏〕

李智慧 · 高并发架构实战课 -〔李智慧〕

结构执行力 -〔李忠秋〕

好记忆不如烂笔头。留下您的足迹吧 :)