in: 后端程序
首字母变大写:ucwords()

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

第一个词首字母变大写: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
//by www.jbxue.com
$foo = 'HelloWorld';
$foo = lcfirst($foo); // helloWorld

$bar = 'HELLO WORLD!';
$bar = lcfirst($bar); // hELLO WORLD!
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
?>

字母变大写:strtoupper()

字母变小写:strtolower()

php字符串首字母转换大小写的实例的更多相关文章

  1. php字符串首字母转换大小写的实例分享

    php中对字符串首字母进行大小写转换的例子. in: 后端程序首字母变大写:ucwords() <?php $foo = 'hello world!'; $foo = ucwords($foo) ...

  2. 用Java将字符串的首字母转换大小写

    在项目开发的时候会需要统一字符串的格式,比如首字母要求统一大写或小写,那用Java如何实现这一功能?下面一起来学习学习. 话不多说,直接上代码 ? 1 2 3 4 5 6 7 8 9 10 11 12 ...

  3. Java将字符串的首字母转换大小写

    //首字母转小写public static String toLowerCaseFirstOne(String s){  if(Character.isLowerCase(s.charAt(0)))  ...

  4. 【Golang】字符串首字母大小写转化

    写在前面 在自动化过程中,我们用得最多的可能就是字符串的处理,熟悉Python的都知道在Python中要让一个字符串的首字母大写直接用capitalize就可以了,但是同样的事情在Golang中没有这 ...

  5. php 中文字符串首字母的获取函数

    这篇文章介绍了php 中文字符串首字母的获取函数,有需要的朋友可以参考一下 function chineseFirst($str) { $str= iconv("UTF-8",&q ...

  6. ms sql 获取字符串首字母

    很久没有编写新文章,现在发布一篇自定义函数,针对于ms sql数据库中需要获取字符串首字母,对于需要的朋友希望对你有用,如果你有更好的方法也可以给我留言.函数如下: --获取字符串首字母 CREATE ...

  7. sql 获取字符串首字母,循环

    //字符串首字母 CREATE FUNCTION GetInitialLetter(@ChineseString NVARCHAR()) RETURNS NVARCHAR() AS BEGIN DEC ...

  8. YTU 2760: 字符串---首字母变大写

    2760: 字符串---首字母变大写 时间限制: 1 Sec  内存限制: 128 MB 提交: 343  解决: 136 题目描述 输入一行英文句子,将每个单词的第一个字母改成大写字母. 输入 一个 ...

  9. PHP将字符串首字母大小写转换

    每个单词的首字母转换为大写:ucwords() <?php $foo = 'hello world!'; $foo = ucwords($foo); // Hello World! $bar = ...

随机推荐

  1. 适用于Magento的最合适的.htaccess写法

    原作者地址:http://www.ctrol.cn/post/ecommercial/magento/12-05-ctrol-4057.html ########################### ...

  2. JS之Array.slice()方法

    1.Array.slice(startIndex,endIndex); 返回由原始数组从startIndex到endIndex-1的元素构成的新数组; startIndex:默认值0,如果startI ...

  3. sqlserver中表变量和变量表之间区别

    sqlserver中表变量和变量表之间区别

  4. php图片处理函数自定义画图和引入图片

    <?php //创建画布,就是画画的位置 imagecreate() //为图像分配颜色 imagecolorallocate() 可以把颜色填充到区域中,不能直接填充画布? //区域填充 bo ...

  5. mongoose的promise(转发)

    Switching out callbacks with promises in Mongoose Published on July 28, 2015 mongo node mongoose pro ...

  6. nc 反弹链接

    nc -l -v -p 80在本机监听80端口,此时80端口是打开的,我们可以在浏览器输入127.0.0.1进行浏览,此时就会出现连接,我们再在监听窗口输入字符,就会在浏览器上显示了.知道上面的作用后 ...

  7. thinkphp扩展 根据前端批量建立字段

    /*批量添加字段辅助*/ function add_colum($tabel){ foreach ($_POST as $key=>$value){ $array[] = "add & ...

  8. pymongo使用总结

    0. 何为pymongo pymongo是操作MongoDB的python模块 1.安装pymongo # easy_install pymongo 2.连接mongodb >>> ...

  9. 堡垒机 paramiko 自动登陆代码

    #!/usr/bin/env python # Copyright (C) - Robey Pointer <robeypointer@gmail.com> # # This file i ...

  10. NETBEANS + XDEBUG + IIS PHP 代码 调试 DEBUG

    参考: http://domainwebcenter.com/?p=936 http://www.sitepoint.com/debugging-and-profiling-php-with-xdeb ...