php中转换首字母大写的函数是什么
- 建站笔记
- 2022-05-12
- 680
在php中,转换首字母大写的函数是ucfirst(),该函数的作用就是将字符串的首字母转化为大写,语法“ucfirst(string)”。
本教程操作环境:windows7系统、PHP7.1版、DELL G3电脑
在php中,想要转换首字母大写,可以使用ucfirst()函数。(相反,想要转换首字母小写,可以使用lcfirst()函数。)
ucfirst 函数能够将字符串的第一个字母转化为大写。语法格式如下:
ucfirst($string)
其中,$string 为需要转化的字符串。
示例:
<?php $str = 'hello world!'; $str = ucfirst($str); echo $str.'<br>'; $str2 = 'HELLO WORLD!'; $str2 = ucfirst(strtolower($str2)); echo $str2; ?>
输出结果:
Hello world! Hello world!
本文由白琉璃于2022-05-12发表在白琉璃源码网,如有侵权或疑问,请联系我们,谢谢。
本文链接:https://www.bailiuli.com/t/2762.html
发表评论