为了照顾刚初学php的朋友们,本章内容就和大家分享一下最基础的知识:php如何转换大小写,我们会用示例来进行讲解。
strtoupper()
所有字母变大写
strtolower()
所有字母变小写
立即学习“PHP免费学习笔记(深入)”;
ucwords()
每个单词的首字母转换为大写
ucfirst()
第一个单词首字母变大写
lcfirst()
第一个单词首字母变小写
示例:
$foo = 'hello world!'; $foo = ucwords($foo); // Hello World! $bar = 'HELLO WORLD!'; $bar = ucwords($bar); // HELLO WORLD! $bar = ucwords(strtolower($bar)); // Hello World! $foo = 'hello world!'; $foo = ucfirst($foo); // Hello world! $bar = 'HELLO WORLD!'; $bar = ucfirst($bar); // HELLO WORLD! $bar = ucfirst(strtolower($bar)); // Hello world! $foo = 'HelloWorld'; $foo = lcfirst($foo); // helloWorld $bar = 'HELLO WORLD!'; $bar = lcfirst($bar); // hELLO WORLD! $bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
以上内容就是PHP转换大小写的详解,希望网对大家有帮助。
相关推荐:
以上就是PHP转换大小写教程基础的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号