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 )
Paramters: This function accepts single parameter $codepoint which is mandotary. 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 code to illustrate IntlChar::isxdigit() // function // Input data is digit type 0-9 var_dump(IntlChar::isxdigit( "0" )); echo "<br>" ; var_dump(IntlChar::isxdigit( "9" )); echo "<br>" ; var_dump(IntlChar::isxdigit( "10" )); echo "<br>" ; // Input data is character type var_dump(IntlChar::isxdigit( "A" )); echo "<br>" ; var_dump(IntlChar::isxdigit( "a" )); echo "<br>" ; var_dump(IntlChar::isxdigit( "F" )); echo "<br>" ; var_dump(IntlChar::isxdigit( "f" )); echo "<br>" ; var_dump(IntlChar::isxdigit( "G" )); echo "<br>" ; var_dump(IntlChar::isxdigit( "g" )); echo "<br>" ; // Input data is FULL ASCII var_dump(IntlChar::isxdigit( "u{0041}" )); echo "<br>" ; var_dump(IntlChar::isxdigit( "u{0046}" )); echo "<br>" ; var_dump(IntlChar::isxdigit( "u{0047}" )); echo "<br>" ; ?> |
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 code to illustrate 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 )); echo "<br>" ; } ?> |
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:
- PHP | IntlChar::isalpha() Function
- PHP | IntlChar::isdigit() Function
- PHP | IntlChar::isbase() Function
Reference: http://php.net/manual/en/intlchar.isxdigit.php
leave a comment
0 Comments