PHP 中的 ctype_xdigit()函数

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

ctype_xdigit() - 语法

ctype_xdigit ( $text );

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

Sr.No Parameter & Description
1

text(必需)

匹配字符串。

ctype_xdigit() - 返回值

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

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

来源:LearnFk无涯教程网

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.

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

技术教程推荐

移动端自动化测试实战 -〔思寒〕

Service Mesh实战 -〔马若飞〕

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

Go 语言项目开发实战 -〔孔令飞〕

数据分析思维课 -〔郭炜〕

手把手教你落地DDD -〔钟敬〕

AI大模型之美 -〔徐文浩〕

云时代的JVM原理与实战 -〔康杨〕

云原生基础架构实战课 -〔潘野〕

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