PHP 中的 ctype_upper() 函数
phpprogrammingserver side programming更新于 2025/11/20 18:16:00
PHP 中的 ctype_upper() 函数检查大写字符。如果文本中的每个字符在当前语言环境中都是大写字母,则返回 TRUE。
语法
ctype_upper(str)
参数
str − 测试的字符串
返回
如果文本中的每个字符在当前语言环境中都是大写字母,则 ctype_upper() 函数返回 TRUE。
示例
下面是一个例子 −
<?php
$arr = array('9898jjhh', 'PQR', 'Amit');
foreach ($arr as $demo) {
if (ctype_upper($demo)) {
echo "$demo has all uppercase letters.
";
} else {
echo "$demo does not have all uppercase letters.
";
}
}
?>
输出
以下是输出 −
9898jjhh does not have all uppercase letters. PQR has all uppercase letters. Amit does not have all uppercase letters.
示例
让我们看另一个例子 −
<?php
$str = 'AUSTRALIA';
if (ctype_upper($str)) {
echo "Word has all uppercase characters!
";
} else {
// 如果为 False 则返回 No
echo "Word does not have all uppercase characters!
";
}
?>
输出
以下是输出 −
Word has all uppercase characters!

