首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

ctype_xdigit

(PHP 4 >= 4.0.4, PHP 5, PHP 7)

ctype_xdigit - 检查代表十六进制数字的字符

描述

代码语言:javascript
复制
bool ctype_xdigit ( string $text )

检查提供的字符串text中的所有字符是否为十六进制“数字”。

参数

text

被测试的字符串。

返回值

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

例子

示例#1一个ctype_xdigit()示例

代码语言:javascript
复制
<?php
$strings?=?array('AB10BC99',?'AR1012',?'ab12bc99');
foreach?($strings?as?$testcase)?{
????if?(ctype_xdigit($testcase))?{
????????echo?"The?string?$testcase?consists?of?all?hexadecimal?digits.\n";
????}?else?{
????????echo?"The?string?$testcase?does?not?consist?of?all?hexadecimal?digits.\n";
????}
}
?>

上面的例子将输出:

代码语言:javascript
复制
The string AB10BC99 consists of all hexadecimal digits.
The string AR1012 does not consist of all hexadecimal digits.
The string ab12bc99 consists of all hexadecimal digits.

注意

注意:如果提供了-128到255之间的整数,则它将被解释为单个字符的ASCII值(为了允许扩展ASCII范围中的字符,负值将被添加256)。任何其他整数都被解释为包含整数的十进制数字的字符串。

扩展内容

  • ctype_digit() - 检查数字字符(s)

← ctype_upper

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com