每个单词的首字母转换为大写:ucwords()
<?php<BR>$foo = 'hello world!';<BR>$foo = ucwords($foo); // Hello World!</P><P>$bar = 'HELLO WORLD!';<BR>$bar = ucwords($bar); // HELLO WORLD!<BR>$bar = ucwords(strtolower($bar)); // Hello World!<BR>?>
第一个单词首字母变大写:ucfirst()
<?php<BR>$foo = 'hello world!';<BR>$foo = ucfirst($foo); // Hello world!</P><P>$bar = 'HELLO WORLD!';<BR>$bar = ucfirst($bar); // HELLO WORLD!<BR>$bar = ucfirst(strtolower($bar)); // Hello world!<BR>?>
第一个单词首字母变小写:lcfirst()
<?php<BR>$foo = 'HelloWorld';<BR>$foo = lcfirst($foo); // helloWorld</P><P>$bar<em style="color:transparent">本@文来源[email protected]搞@^&代*@码网(</em><q>搞代gaodaima码</q> = 'HELLO WORLD!';<BR>$bar = lcfirst($bar); // hELLO WORLD!<BR>$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!<BR>?>
所有字母变大写:strtoupper()
所有字母变小写:strtolower()