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. Almost Sorted Array---hdu5532(简单dp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5532 题意:问一个含有n个数的序列,删除一个数后是否有序(递增或递减都可以) 我们只要求一下最长上升子 ...

  2. Java学习-015-CSV 文件写入实例源代码

    在日常的自动化测试脚本编写的过程中,有时要将获取的测试结果或者测试数据存放在数据文件中,以用作后续的参数化测试.常用的文件文件类型无非 txt.csv.xls.properties.xml 这五种文件 ...

  3. <dependency>spring-webmvc</dependency>

    Spring 4.2.0.RELEASE版本: <dependency> <groupId>org.springframework</groupId> <ar ...

  4. Recompile the invalid object for oracle.

    1. How does the invalid object come? The Oracle database will invalidate objects if a dependent obje ...

  5. Android --SwipeRefreshLayout 下拉刷新

    1.Layout <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/id_swipe_ly" an ...

  6. Linux系统 ssh图形界面远程

    远程Linux系统有图形界面 1.下载xming 并安装启动 2.通过putty登陆虚拟机 3.输入gnome-session

  7. 使用NSData处理数据

    // //  main.m //  06-使用NSData处理数据 // //  Created by apple on 14-3-21. //  Copyright (c) 2014年 apple. ...

  8. Java 杨辉三角的简单实现

    package com.lf.trianglenumber; public class Test { public static void main(String[] args) { // 打印的行数 ...

  9. Java基础之线程——使用执行器(UsingExecutors)

    控制台程序. 在这个版本的银行示例中,把借款和贷款事务创建为在不同线程中执行的任务,它们把事务提交给职员.创建事务的任务是Callable<>任务,因为它们需要返回已为每个账户创建的借款或 ...

  10. 【转】Tomcat组件生命周期管理

    Tomcat组件生命周期管理 Tomcat中Server,Service,Connector,Engine,Host,Context,它们都实现了org.apache.catalina.Lifecyc ...