易洋国学旗下网站:
查询

ctype_lower()函数—用法及示例

「 检查给定的字符串中的字符是否都是小写字母 」


函数名称: ctype_lower()

函数描述:检查给定的字符串中的字符是否都是小写字母。

适用版本:自 PHP 4 起可用。

用法:

bool ctype_lower ( string $text )

参数:

  • $text:要检查的字符串。

返回值:

  • 如果 $text 中的所有字符都是小写字母,则返回 true,否则返回 false

示例:

$text = "hello";

if (ctype_lower($text)) {
    echo "All characters in the string are lowercase.";
} else {
    echo "String contains characters other than lowercase.";
}

输出:

All characters in the string are lowercase.

在上述示例中,我们使用 ctype_lower() 函数来检查字符串 $text 中的字符是否都是小写字母。因为字符串 "hello" 中的所有字符都是小写字母,所以输出显示所有字符都是小写字母。如果我们将字符串更改为 "Hello",那么函数的输出将会是 "String contains characters other than lowercase.",因为字符串中包含了非小写字母的字符。

补充纠错
上一个函数: ctype_graph()函数
下一个函数: ctype_print()函数
热门PHP函数
分享链接