微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php中字符串大小写转换

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

$str="hello world";

echo ucfirst($str);

运行结果为:

Hello world 

lcfirst() - 把字符串中的首字符转换为小写

$str="Hello world";

echo lcfirst($str);

运行结果为:

hello world

strtolower() - 把字符串转换为小写

$str="Hello world";

echo strtolower($str);

运行结果为:

hello world

strtoupper() - 把字符串转换为大写

$str="hello world";

echo strtoupper($str);

运行结果为:

HELLO WORD

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

$str="hello world";

echo strtoupper($str);

运行结果为:

Hello World

lcfirst() - 将字符串中的首字符转换为小写

$str="HELLO WORLD";

echo lcfirst($str)."<br>";

运行结果为:

hELLO WORLD

strtolower() - 将整个字符串转换为小写

$str="HELLO WORLD";

echo strtolower($str)."<br>";

运行结果为:

hello world

strtoupper() - 将整个字符串转换为大写

$str="hello WORLD";

echo strtoupper($str)."<br>";

运行结果为:

HELLO WORLD

ucwords() - 将字符串中每个单词的首字符转换为大写

$str="hello world";

echo ucwords($str)."<br>";

运行结果为:

Hello World


版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐