Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

ctype_xdigit

Description

The ctype_xdigit of Ctype for PHP checks for character(s) representing a hexadecimal digit.

Syntax

ctype_xdigit(
    mixed $text
): bool

Parameters

text

The tested string.

NOTE: If an integer between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string containing the decimal digits of the integer.

Return

Returns true if every character in text is a hexadecimal 'digit', that is a decimal digit or a character from [A-Fa-f] , false otherwise.

When called with an empty string the result will always be false.

Examples

1 · text

<?

$text = "0123456789ABCDEFabcdef";

$return = ctype_xdigit($text);

var_export($return);

?>
true

2

<?

for($i = 0; $i <= 255; ++$i)
{
    $return = ctype_xdigit($i);

    if($return)
    {
        $character = chr($i);

        echo "$i: $character\n";
    }
}

?>
48: 0
49: 1
50: 2
51: 3
52: 4
53: 5
54: 6
55: 7
56: 8
57: 9
65: A
66: B
67: C
68: D
69: E
70: F
97: a
98: b
99: c
100: d
101: e
102: f
HomeMenu