ctype_xdigit

(PHP 4 >= 4.0.4, PHP 5, PHP 7)

ctype_xdigit 锟斤拷锟斤拷址锟斤拷锟斤拷欠锟街伙拷锟斤拷锟绞拷锟斤拷锟斤拷锟斤拷址锟�

说锟斤拷

ctype_xdigit ( string $text ) : bool

锟斤拷锟� string 锟斤拷 text 锟斤拷锟斤拷锟斤拷址锟斤拷遣锟斤拷嵌锟斤拷锟绞拷锟斤拷锟斤拷锟斤拷址锟斤拷锟斤拷锟�

锟斤拷锟斤拷

text

锟斤拷要锟斤拷锟斤拷锟皆碉拷锟街凤拷锟斤拷锟斤拷

锟斤拷锟斤拷值

锟斤拷锟� text 锟斤拷锟斤拷锟矫匡拷锟斤拷址锟斤拷锟斤拷锟绞拷锟斤拷锟斤拷锟斤拷址锟斤拷锟揭诧拷锟斤拷锟街伙拷馨锟斤拷锟绞拷锟斤拷频锟斤拷锟街︼拷锟� [A-Fa-f] 锟斤拷锟斤拷母锟斤拷锟斤拷锟津,凤拷锟斤拷 FALSE 锟斤拷

锟斤拷锟斤拷

Example #1 一锟斤拷 ctype_xdigit() 锟斤拷锟斤拷锟斤拷

<?php
$strings 
= array('AB10BC99''AR1012''ab12bc99');
foreach (
$strings as $testcase) {
    if (
ctype_xdigit($testcase)) {
        echo 
"The string $testcase consists of all hexadecimal digits.\n";
    } else {
        echo 
"The string $testcase does not consist of all hexadecimal digits.\n";
    }
}
?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

The string AB10BC99 consists of all hexadecimal digits.
The string AR1012 does not consist of all hexadecimal digits.
The string ab12bc99 consists of all hexadecimal digits.

注锟斤拷

Note:

锟斤拷锟斤拷锟斤拷锟揭伙拷锟� -128 锟斤拷 255 之锟斤拷(锟斤拷)锟斤拷锟斤拷锟斤拷, 锟斤拷锟结被锟斤拷锟斤拷为锟斤拷值锟斤拷应锟斤拷ASCII锟街凤拷 (锟斤拷值锟斤拷锟斤拷锟斤拷 256 锟斤拷支锟斤拷锟斤拷展ASCII锟街凤拷). 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟结被锟斤拷锟斤拷为锟斤拷值锟斤拷应锟斤拷十锟斤拷锟斤拷锟街凤拷锟斤拷.

锟轿硷拷