欢迎光临
我们一直在努力

php首字母小写怎么转大写

php首字母小写转大写的方法

每个单词的首字母转换为大写:ucwords()

<?php
$foo = 'hello world!';
$foo = ucwords($foo);             // Hello World!
 
$bar = 'HELLO WORLD!';
$bar = ucwords($bar);             // HELLO WORLD!
$bar = ucwords(strtolower($bar)); // Hello World!
?>

ucwords() 函数把字符串中每个单词的首字符转换为大写。

第一个单词首字母变大写:ucfirst()

<?php
$foo = 'hello world!';
$foo = ucfirst($foo);             // Hello world!
 
$bar = 'HELLO WORLD!';
$bar = ucfirst($bar);             // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>

ucfirst() 函数把字符串中的首字符转换为大写。

以上就是php首字母小写怎么转大写的详细内容,更多请关注VIP共享吧其它相关文章!

赞(0) 打赏
未经允许不得转载:码农资源网 » php首字母小写怎么转大写
分享到

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册