PHP字符串大小写转化相关函数

【小结】

  • 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!

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值