Php-function-ctype-alnum
提供:Dev Guides
PHP-関数ctype_alnum()
構文
ctype_alnum ( $text );
定義と使い方
指定された文字列、テキスト内のすべての文字が英数字かどうかをチェックします。 標準Cロケールでは、文字は[A-Za-z]であり、関数はpreg_match( '/^ [a-z0-9] + $/iD'、$ text)と同等です。
パラメーター
Sr.No | Parameters & Description |
---|---|
1 |
text(Required) テストされた文字列。 |
戻り値
テキスト内のすべての文字が文字または数字の場合はTRUE、そうでない場合はFALSEを返します。
例
次の例を試してください-
<?php
$strings = array('hello', 'foo!#$bar');
foreach ($strings as $example) {
if (ctype_alnum($example)) {
echo "$example consists of all letters or digits. \n";
}else {
echo "$example does not have all letters or digits. \n";
}
}
?>
これは、次の結果を生成します-
hello consists of all letters or digits.
foo!#$bar does not have all letters or digits.