Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function ctype_xdigit()


previous

Advertisements

Syntax

ctype_xdigit ( $text );

Definition and Usage

This function checks if all of the characters in the provided string, text, are hexadecimal 'digits'.

Paramters

ParameterDescription
textRequired. The tested string.

Return Value

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.

Example

Try out following example:

<?php
$strings = array('AB10BC99', 'AR1012', 'ab12bc99');
foreach ($strings as $testcase) {
 if (ctype_xdigit($testcase)) {
     echo "$testcase consists of all hexadecimal digits.<br />";
 } else {
     echo "$testcase does not have all hexadecimal digits.<br />";
 }
}
?> 

This will produce following result:

AB10BC99 consists of all hexadecimal digits.
AR1012 does not have all hexadecimal digits.
ab12bc99 consists of all hexadecimal digits.

previous Printer Friendly

Advertisements


  

Advertisements