Syntax
| ctype_xdigit ( $text ); |
Definition and Usage
This function checks if all of the characters in the provided string, text, are hexadecimal 'digits'.
Paramters
| Parameter | Description |
|---|---|
| text | Required. 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. |
No comments:
Post a Comment