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.

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

技术教程推荐

趣谈网络协议 -〔刘超〕

全栈工程师修炼指南 -〔熊燚(四火)〕

安全攻防技能30讲 -〔何为舟〕

数据中台实战课 -〔郭忆〕

Web安全攻防实战 -〔王昊天〕

etcd实战课 -〔唐聪〕

零基础实战机器学习 -〔黄佳〕

结构思考力 · 透过结构看思考 -〔李忠秋〕

结构会议力 -〔李忠秋〕

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