Php-function-ctype-xdigit
提供:Dev Guides
PHP-関数ctype_xdigit()
構文
ctype_xdigit ( $text );
定義と使い方
この関数は、指定された文字列であるテキストのすべての文字が16進数の「数字」であるかどうかをチェックします。
パラメーター
Sr.No | Parameter & Description |
---|---|
1 |
text(Required) テストされた文字列。 |
戻り値
テキスト内のすべての文字が16進数の「数字」、つまり10進数字または[A-Fa-f]の文字である場合はTRUE、そうでない場合はFALSEを返します。
例
次の例を試してください-
<?php
$strings = array('ABCDEF', 'SAI!@#$', 'ab12bc99');
foreach ($strings as $test) {
if (ctype_xdigit($test)) {
echo "$test consists of all hexadecimal digits. \n";
}else {
echo "$test does not have all hexadecimal digits. \n";
}
}
?>
これは、次の結果を生成します-
ABCDEF consists of all hexadecimal digits.
SAI!@#$ does not have all hexadecimal digits.
ab12bc99 consists of all hexadecimal digits.