$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
$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
$str="hello WORLD";
echo strtoupper($str)."<br>";
运行结果为:
HELLO WORLD
ucwords() - 将字符串中每个单词的首字符转换为大写
$str="hello world";
echo ucwords($str)."<br>";
运行结果为:
Hello World