ctype_upper()函數(shù)檢查字符串里面的字符是不是都是大寫字母。
ctype_upper ( $text );
此函數(shù)檢查所提供的字符串(文本)中的所有字符是否均為大寫字母。
| 序號 | 參數(shù)及說明 |
|---|---|
| 1 | text(必需) 被測試的字符串。 |
如果文本中的每個字符在當(dāng)前語言環(huán)境中均為大寫字母,則返回TRUE。
檢測字符串中,是否所有字母均為大寫,注意看以下示例
<?php
$strings = array('test12345', 'ABCEFG','222ADFDS','testText');
foreach ($strings as $test) {
if (ctype_upper($test)) {
echo "$test 全部為大寫字母 \n";
}else {
echo "$test 不全為大寫字母 \n";
}
}
?>測試看看?/?輸出結(jié)果
test12345 不全為大寫字母 ABCEFG 全部為大寫字母 222ADFDS 不全為大寫字母 testText 不全為大寫字母