php中英文字符转换大小字代码教程
发布时间:2023-11-07 10:31:35 所属栏目:PHP教程 来源:转载
导读: 每个单词的首字母转换为大写: ucwords()
第一个单词首字母变大写: ucfirst()
第一个单词首字母变小写: lcfirst()
所有 字母变大写: strtoupper()
第一个单词首字母变大写: ucfirst()
第一个单词首字母变小写: lcfirst()
所有 字母变大写: strtoupper()
每个单词的首字母转换为大写: ucwords() 第一个单词首字母变大写: ucfirst() 第一个单词首字母变小写: lcfirst() 所有 字母变大写: strtoupper() 例子 代码如下 1 echo strtoupper("Hello WORLD!"); ?> 2 输出: 3 HELLO WORLD! 第一个单词首字母变大写:ucfirst() 代码如下 1 $foo = 'where are doing?!'; $foo = ucfirst($foo); // where are doing?! 2 $bar = 'where are doing?!'; $bar = ucfirst($bar); // where are doing?! $bar = ucfirst(strtolower($bar)); // where are doing?! ?> 所有 字母变小写: strtolower() 代码如下 1 $str = "Mary Had A Little Lamb and She LOVED It So"; $str = strtolower($str); echo $str; // Prints mary had a little lamb and she loved it so ?> 每个单词的首字母转换为大写:ucwords() 代码如下 1 $foo = 'where are doing?!'; $foo = ucwords($foo); // Where are doing?! 2 $bar = 'where are doing?!'; $bar = ucwords($bar); // Where are doing?! $bar = ucwords(strtolower($bar)); // Where are doing?! ?> 第一个单词首字母变小写:lcfirst() 代码如下 1 $foo = 'HelloWorld'; $foo = lcfirst($foo); // where are doing 2 $bar = 'where are doing?!'; $bar = lcfirst($bar); // where are doing?! $bar = lcfirst(strtoupper($bar)); // where are doing?! ?> (编辑:92站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐