ctype_upper()函数检查字符串里面的字符是不是都是大写字母。
ctype_upper ( $text );
此函数检查所提供的字符串(文本)中的所有字符是否均为大写字母。
| 序号 | 参数及说明 |
|---|---|
| 1 | text(必需) 被测试的字符串。 |
如果文本中的每个字符在当前语言环境中均为大写字母,则返回TRUE。
检测字符串中,是否所有字母均为大写,注意看以下示例
<?php
$strings = array('test12345', 'ABCEFG','222ADFDS','testText');
foreach ($strings as $test) {
if (ctype_upper($test)) {
echo "$test 全部为大写字母 \n";
}else {
echo "$test 不全为大写字母 \n";
}
}
?>测试看看‹/›输出结果
test12345 不全为大写字母 ABCEFG 全部为大写字母 222ADFDS 不全为大写字母 testText 不全为大写字母