Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
687 views
in Technique[技术] by (71.8m points)

php - How do I echo text in capital letters?

I want to know how to capitalize in PHP

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
echo strtoupper('hello');

strtoupper will capitalize the whole string.

If you're only interested in capitalizing the first letter, you can use ucfirst:

echo ucfirst('hello!'); //Hello!

If you want to capitalize the first letter of each word in a string, use ucwords:

echo ucwords('hello world!'); //Hello World!

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...