字母和数字输入的Ctype函数

时间:2018-01-23 10:19:49

标签: php ctype

是否可以检查输入是否包含带Ctype的字母和数字字符?

1 个答案:

答案 0 :(得分:0)

ctype_alnum

<?php
$strings = array('AbCd1zyZ9', 'foo!#$bar');
foreach ($strings as $testcase) {
    if (ctype_alnum($testcase)) {
        echo "The string $testcase consists of all letters or digits.\n";
    } else {
        echo "The string $testcase does not consist of all letters or digits.\n";
    }
}
?>