PHP ucfirst() 函數
實例
把 "hello" 的首字元轉換為大寫:
<?php
echo ucfirst("hello world!");
?>
echo ucfirst("hello world!");
?>
定義和用法
ucfirst() 函數把字串中的首字元轉換為大寫。
相關函數:
- lcfirst() - 把字串中的首字元轉換為小寫
- ucwords() - 把字串中每個單詞的首字元轉換為大寫
- strtoupper() - 把字串轉換為大寫
- strtolower() - 把字串轉換為小寫
語法
ucfirst(string)
參數 | 描述 |
---|---|
string | 必需。規定要轉換的字串。 |
技術細節
返回值: | 返回已轉換的字串。 |
---|---|
PHP 版本: | 4+ |
