(PHP 4, PHP 5, PHP 7, PHP 8)
ucfirst — 將字符串的首字母轉換為大寫
$str
將 str 的首字符(如果首字符是字母)轉換為大寫字母,并返回這個字符串。
str
注意字母的定義取決于當前區(qū)域設定。例如,在默認的 “C” 區(qū)域,字符 umlaut-a(?)將不會被轉換。
輸入字符串。
返回結果字符串。
示例 #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!?>