PHP 大小写转换函数 lcfirst ucfirst ucwords strtolower strtoupper
- lcfirst – 将字符串的首字母转换为小写 (PHP 5 >= 5.3.0, PHP 7)
- ucfirst – 将字符串的首字母转换为大写 (PHP 4, PHP 5, PHP 7)
- ucwords – 将字符串中每个单词的首字母转换为大写 (PHP 4, PHP 5, PHP 7)
- strtolower – 将字符串转化为小写 (PHP 4, PHP 5, PHP 7)
- strtoupper – 将字符串转化为大写 (PHP 4, PHP 5, PHP 7)
lcfirst
将字符串的首字母转换为小写
string lcfirst ( string $str )
参数说明
str
输入的字符串。
返回值
返回转换后的字符串。
注意
如果str的第一个字符是字母,则将其转换为小写。需要注意的是“字母”是由当前语言区域决定的。
示例
<?php
$foo = 'HelloWorld';
$foo = lcfirst($foo);
var_dump($foo); //string 'helloWorld' (length=10)
$foo = 'helloWorld';
$foo = lcfirst($foo);
var_dump($foo); //string 'helloWorld' (length=10)
$foo = '中文';