ucfirst
(PHP 4, PHP 5, PHP 7)
ucfirst - 使字符串的第一个字符大写
描述
string ucfirst ( string $str )
如果该字符是字母,则返回一个字符串,其中第一个字符是str的大写形式。
请注意,“字母”由当前语言环境决定。例如,默认的“C”语言环境字符(如umlaut-a(?))将不会被转换。
参数
str
输入字符串。
返回值
返回结果字符串。
例子
示例#1 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() - 使字符串的第一个字符小写
- strtolower() - 使字符串小写
- strtoupper() - 使字符串大写
- ucwords() - 大写字符串中每个单词的第一个字符
← trim
ucwords →
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com