• 技术文章 >后端开发 >php教程

    PHP转换大小写教程基础

    小云云小云云2017-11-28 09:24:59原创772
    为了照顾刚初学php的朋友们,本章内容就和大家分享一下最基础的知识:PHP如何转换大小写,我们会用示例来进行讲解。

    strtoupper()

    所有字母变大写

    strtolower()

    所有字母变小写

    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转换大小写的详解,希望网对大家有帮助。

    相关推荐:

    python中转换大小写的方法

    php字符串首字母转换大小写实例_PHP教程

    php字符串首字母转换大小写

    以上就是PHP转换大小写教程基础的详细内容,更多请关注php中文网其它相关文章!

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:php 大小写 基础
    上一篇:Yii2实现增删改查后留在当前页的方法详解 下一篇:日期正则表达式总结
    20期PHP线上班

    相关文章推荐

    • 【活动】充值PHP中文网VIP即送云服务器• PHP如何使用xlswriter进行大数据的导入导出?(详解)• 自动跳转中英文页面_PHP教程• PHP5的XML新特性_PHP教程• 深入浅析php json 格式控制• PHP开发经验总结
    1/1

    PHP中文网