PHP

首页 -  PHP  -  php中字符串大小写转换

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


(0)
分享:

本文由:xiaoshu168 作者:xiaoshu发表,转载请注明来源!

标签:

相关阅读