php中强制字母转换大小写的方法有哪些

互联网 19-12-2

strtoupper() 函数把字符串转换为大写。

strtolower() 函数把字符串转换为小写。

每个单词的首字母转换为大写:ucwords()

<?php $foo = 'hello world!'; $foo = ucwords($foo);             // Hello World!  $bar = 'HELLO WORLD!'; $bar = ucwords($bar);             // HELLO WORLD! $bar = ucwords(strtolower($bar)); // Hello World! ?>

在线学习视频推荐:php视频教程

第一个单词首字母变大写:ucfirst()

<?php $foo = 'hello world!'; $foo = ucfirst($foo);             // Hello world! $bar = 'HELLO WORLD!'; $bar = ucfirst($bar);             // HELLO WORLD! $bar = ucfirst(strtolower($bar)); // Hello world! ?>

第一个单词首字母变小写:lcfirst()

<?php $foo = 'HelloWorld'; $foo = lcfirst($foo);             // helloWorld $bar = 'HELLO WORLD!'; $bar = lcfirst($bar);             // hELLO WORLD! $bar = lcfirst(strtoupper($bar)); // hELLO WORLD! ?>

相关文章教程推荐:php教程

以上就是php中强制字母转换大小写的方法有哪些的详细内容,更多内容请关注技术你好其它相关文章!

来源链接:
免责声明:
1.资讯内容不构成投资建议,投资者应独立决策并自行承担风险
2.本文版权归属原作所有,仅代表作者本人观点,不代表本站的观点或立场
标签: 方法
上一篇:php获取远程图片并下载保存到本地的方法分析 下一篇:php中如何判断字母是大写还是小写

相关资讯