【小结】
-
lcfirst —使一个字符串的第一个字符小写。
-
ucfirst — 将字符串的首字母转换为大写。
-
strtolower — 将字符串转化为小写。
-
strtoupper — 将字符串转化为大写。
-
ucwords — 将字符串中每个单词的首字母转换为大写。
//大小写转化
//lcfirst 返回第一个字母小写的 str ,如果是字母的话。
echo lcfirst('Hello Tacks!'),'<br/>';//hello Tacks!
echo lcfirst('9Hello Tacks!'),'<br/>';//9Hello Tacks!
//ucfirst 将 str 的首字符(如果首字符是字母)转换为大写字母,并返回这个字符串。
echo ucfirst('hello tacks!'),'<br/>';//Hello tacks!
echo ucfirst('9hello tacks!'),'<br/>';//9hello tacks!
//strtolower 将 string 中所有的字母字符转换为小写并返回。
echo strtolower('HELLO TACKS!'),'<br/>';//hello tacks!
//strtoupper 将 string 中所有的字母字符转换为大写并返回。
echo strtoupper('hello tacks!'),'<br/>';//HELLO TACKS!
//ucwords 将 str 中每个单词的首字符(如果首字符是字母)转换为大写字母,并返回这个字符串。
echo ucwords('hello,this is my dog!'),'<br/>';//Hello,this Is My Dog!
本文介绍了PHP中用于字符串大小写转换的五个主要函数:lcfirst、ucfirst、strtolower、strtoupper和ucwords。通过实例展示了如何使用这些函数来改变字符串中字母的大小写,包括将首字母转换为小写或大写,将整个字符串转换为全小写或全大写,以及将每个单词的首字母转换为大写。
474

被折叠的 条评论
为什么被折叠?



