【发布时间】:2018-07-02 03:04:40
【问题描述】:
有没有办法用 Ctype 检查输入是否同时包含字母和数字字符?
【问题讨论】:
-
你试过
ctype_alnum函数吗?
有没有办法用 Ctype 检查输入是否同时包含字母和数字字符?
【问题讨论】:
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";
}
}
?>
【讨论】: