做程序开发处理字符串是再正常不过的事了,字母大小写转换主要涉及以下五个函数:
lcfirst() 函数把字符串中的首字符转换为小写。
ucfirst() 把字符串中的首字符转换为大写。
ucwords() 把字符串中每个单词的首字符转换为大写。
strtoupper() 把字符串转换为大写。
strtolower() 把字符串转换为小写。
示例:
$str1='Hello word';
$str2='hello word';
echo lcfirst($str1);
输出:hello word
echo ucfirst($str2);
输出:Hello word
echo ucwords($str2);
输出:Hello Word
echo strtoupper($str1);
输出:HELLO WORD
echo strtolower($str1);
输出:hello word