源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

PHP英文字母大小写转换函数小结

  • 时间:2020-08-17 19:53 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:PHP英文字母大小写转换函数小结
每个单词的首字母转换为大写:ucwords()
[u]复制代码[/u] 代码如下:
<?php $foo = 'hello world!'; $foo = ucwords($foo);             // Hello World! $bar = 'HELLO WORLD!'; $bar = ucwords($bar);             // HELLO WORLD! $bar = ucwords(strtolower($bar)); // Hello World! ?>
第一个单词首字母变大写:ucfirst()
[u]复制代码[/u] 代码如下:
<?php $foo = 'hello world!'; $foo = ucfirst($foo);             // Hello world! $bar = 'HELLO WORLD!'; $bar = ucfirst($bar);             // HELLO WORLD! $bar = ucfirst(strtolower($bar)); // Hello world! ?>
第一个单词首字母变小写:lcfirst()
[u]复制代码[/u] 代码如下:
<?php $foo = 'HelloWorld'; $foo = lcfirst($foo);             // helloWorld $bar = 'HELLO WORLD!'; $bar = lcfirst($bar);             // hELLO WORLD! $bar = lcfirst(strtoupper($bar)); // hELLO WORLD! ?>
所有字母变大写:strtoupper() 所有字母变小写:strtolower()
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部