PHP | IntlChar::isxdigit() Function
Last Updated :
11 Jul, 2025
The IntlChar::isxdigit() function is an inbuilt function in PHP which is used to check whether the given input character is a hexadecimal digit or not. It is TRUE for decimal digit numbers (0 - 9), Latin letters (a - f) and (A - F) in both ASCII and Fullwidth ASCII (Letters with codepoint \u{0041} to \u{0046}, \u{0061} to \u{0066}, \u{FF21} to \u{FF26} and \u{FF41} to \u{FF46}).
Syntax:
bool IntlChar::isxdigit( $codepoint )
Parameters: This function accepts a single parameter $codepoint which is mandatory. The input parameter is an integer values or character, which is encoded as a UTF-8 string.
Return Value: If $codepoint is a hexadecimal digit then it returns True, otherwise return False.
Below programs illustrate the IntlChar::isxdigit() function in PHP:
Program 1:
PHP
<?php
// PHP code to illustrate IntlChar::isxdigit()
// function
// Input data is digit type 0-9
var_dump(IntlChar::isxdigit("0"));
var_dump(IntlChar::isxdigit("9"));
var_dump(IntlChar::isxdigit("10"));
// Input data is character type
var_dump(IntlChar::isxdigit("A"));
var_dump(IntlChar::isxdigit("a"));
var_dump(IntlChar::isxdigit("F"));
var_dump(IntlChar::isxdigit("f"));
var_dump(IntlChar::isxdigit("G"));
var_dump(IntlChar::isxdigit("g"));
// Input data is FULL ASCII
var_dump(IntlChar::isxdigit("\u{0041}"));
var_dump(IntlChar::isxdigit("\u{0046}"));
var_dump(IntlChar::isxdigit("\u{0047}"));
?>
Output:
bool(true)
bool(true)
NULL
bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
bool(false)
bool(true)
bool(true)
bool(false)
Program 2:
PHP
<?php
// PHP code to illustrate IntlChar::isxdigit()
// Declare an array $arr
$arr = array("0", "9", "a", "A", "f", "\u{0041}",
"\u{0066}", "\u{0067}", "G", "10", "Geeks");
// Loop run for every array element
foreach ($arr as $val){
// Check each element as code point data
var_dump(IntlChar::isxdigit($val));
}
?>
Output:
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
bool(false)
NULL
NULL
Note: IntlChar::isxdigit() is equivalent to IntlChar::digit($codepoint, 16) >= 0.
Related Articles:
Reference: https://www.php.net/manual/en/intlchar.isxdigit.php