PHP英文字母大小写转换函数小结


Posted in PHP onMay 03, 2014

每个单词的首字母转换为大写: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
$foo = 'HelloWorld';
$foo = lcfirst($foo);             // helloWorld
$bar = 'HELLO WORLD!';
$bar = lcfirst($bar);             // hELLO WORLD!
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
?>

所有字母变大写:strtoupper()
所有字母变小写:strtolower()

PHP 相关文章推荐
综合图片计数器
Oct 09 PHP
《PHP边学边教》(04.编写简易的通讯录――视频教程1)
Dec 13 PHP
php 需要掌握的东西 不做浮躁的人
Dec 28 PHP
php file_put_contents()功能函数(集成了fopen、fwrite、fclose)
May 24 PHP
强烈声明: 不要使用(include/require)_once
Jun 06 PHP
php以fastCGI的方式运行时文件系统权限问题及解决方法
May 11 PHP
PHP判断来访是搜索引擎蜘蛛还是普通用户的代码小结
Sep 14 PHP
表单提交错误后返回内容消失问题的解决方法(PHP网站)
Oct 20 PHP
Yii中实现处理前后台登录的新方法
Dec 28 PHP
深入解析PHP的Laravel框架中的event事件操作
Mar 21 PHP
ThinkPHP项目分组配置方法分析
Mar 23 PHP
php使用number_format函数截取小数的方法分析
May 27 PHP
php获取网卡的MAC地址支持WIN/LINUX系统
Apr 30 #PHP
php环境无法上传文件的解决方法
Apr 30 #PHP
php分页示例分享
Apr 30 #PHP
yii框架配置默认controller和action示例
Apr 30 #PHP
yii框架通过控制台命令创建定时任务示例
Apr 30 #PHP
yii框架builder、update、delete使用方法
Apr 30 #PHP
yii框架表单模型使用及以数组形式提交表单数据示例
Apr 30 #PHP
You might like
国产动画《伍六七》原声大碟大卖,啊哈娱乐引领音乐赋能IP的新尝试
2020/03/08 国漫
php数组函数序列之array_search()- 按元素值返回键名
2011/11/04 PHP
PHP面向对象法则
2012/02/23 PHP
php通过正则表达式记取数据来读取xml的方法
2015/03/09 PHP
PHP用户管理中常用接口调用实例及解析(含源码)
2017/03/09 PHP
基于ThinkPHP5.0实现图片上传插件
2017/09/25 PHP
PHP实现合并两个排序链表的方法
2018/01/19 PHP
PHP抽象类与接口的区别详解
2019/03/21 PHP
TNC vs RR BO3 第一场 2.14
2021/03/10 DOTA
jquery学习笔记二 实现可编辑的表格
2010/04/09 Javascript
Javascript获取窗口(容器)的大小及位置参数列举及简要说明
2012/12/09 Javascript
JQuery for与each性能比较分析
2013/05/14 Javascript
使用js Math.random()函数生成n到m间的随机数字
2014/10/09 Javascript
javascript简单实现类似QQ头像弹出效果的方法
2015/08/03 Javascript
jQuery使用$.ajax进行异步刷新的方法(附demo下载)
2015/12/04 Javascript
Javascript基础_简单比较undefined和null 值
2016/06/14 Javascript
微信小程序 图片等比例缩放(图片自适应屏幕)
2016/11/16 Javascript
JS实现最简单的冒泡排序算法
2017/02/15 Javascript
基于JavaScript实现拖动滑块效果
2017/02/16 Javascript
nodejs连接mysql数据库简单封装示例-mysql模块
2017/04/10 NodeJs
angular6.x中ngTemplateOutlet指令的使用示例
2018/08/09 Javascript
webpack 动态批量加载文件的实现方法
2020/03/19 Javascript
Python标准库之sqlite3使用实例
2014/11/25 Python
详解python string类型 bytes类型 bytearray类型
2017/12/16 Python
Python面向对象程序设计OOP深入分析【构造函数,组合类,工具类等】
2019/01/05 Python
详解Python3中setuptools、Pip安装教程
2019/06/18 Python
Java Spring项目国际化(i18n)详细方法与实例
2020/03/20 Python
html5 canvas移动浏览器上实现图片压缩上传
2016/03/11 HTML / CSS
使用html5新特性轻松监听任何App自带返回键的示例
2018/03/13 HTML / CSS
经济管理专业毕业生推荐信
2013/11/11 职场文书
开业庆典答谢词
2014/01/18 职场文书
村庄环境整治方案
2014/05/15 职场文书
紧急通知
2015/04/17 职场文书
Python基础知识学习之类的继承
2021/05/31 Python
一文搞懂python异常处理、模块与包
2021/06/26 Python
Pandas搭配lambda组合使用详解
2022/01/22 Python