如何在大写字母中回显文本?
问题描述:
我想知道如何在PHP中大写
I want to know how to capitalize in PHP
答
echo strtoupper('hello');
strtoupper 将大写整个字符串。
如果您只对首字母大写感兴趣,则可以使用 ucfirst :
If you're only interested in capitalizing the first letter, you can use ucfirst:
echo ucfirst('hello!'); //Hello!
如果要大写字符串中每个单词的首字母,请使用 ucwords :
If you want to capitalize the first letter of each word in a string, use ucwords:
echo ucwords('hello world!'); //Hello World!