PHP 中的 ctype_xdigit()函数

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

ctype_xdigit() - 语法

ctype_xdigit ( $text );

此函数检查提供的字符串text中的所有字符是否都是十六进制的"xdigit 数字"。

Sr.No Parameter & Description
1

text(必需)

匹配字符串。

链接:https://www.learnfk.comhttps://www.learnfk.com/php/php-function-ctype-xdigit.html

来源:LearnFk无涯教程网

ctype_xdigit() - 返回值

如果文本中的每个字符都是十六进制数字,即十进制数字或[A-Fa-f]中的字符,则返回TRUE,否则返回FALSE。

ctype_xdigit() - 示例

<?php
   $strings=array('ABCDEF', 'SAI!@#$', 'ab12bc99');
   
   foreach ($strings as $test) {
      if (ctype_xdigit($test)) {
         echo "$test consists of all hexadecimal digits.\n";
      }else {
         echo "$test does not have all hexadecimal digits.\n";
      }
   }
?> 

这将产生以下输出-

ABCDEF consists of all hexadecimal digits.
SAI!@#$does not have all hexadecimal digits.
ab12bc99 consists of all hexadecimal digits.

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

技术教程推荐

微服务架构核心20讲 -〔杨波〕

从0开始学架构 -〔李运华〕

技术管理实战36讲 -〔刘建国〕

玩转Git三剑客 -〔苏玲〕

人人都用得上的数字化思维课 -〔付晓岩〕

计算机基础实战课 -〔彭东〕

Go进阶 · 分布式爬虫实战 -〔郑建勋〕

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

手把手带你写一个 MiniTomcat -〔郭屹〕

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