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
var_dump(IntlChar::isxdigit( "0" ));
var_dump(IntlChar::isxdigit( "9" ));
var_dump(IntlChar::isxdigit( "10" ));
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" ));
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
$arr = array ( "0" , "9" , "a" , "A" , "f" , "\u{0041}" ,
"\u{0066}" , "\u{0067}" , "G" , "10" , "Geeks" );
foreach ( $arr as $val ){
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: http://php.net/manual/en/intlchar.isxdigit.php