函式名稱:lcfirst()
函式描述:lcfirst() 函式將字串的首字母轉換為小寫。
適用版本:PHP 5,PHP 7
用法: string lcfirst ( string $str )
引數:
- $str: 必需。要轉換的字串。
返回值:返回轉換後的字串。
示例:
$str = "HelloWorld";
$result = lcfirst($str);
echo $result;
輸出:
helloWorld
解釋:
在上面的示例中,我們首先定義了一個字串變數 $str
,其值為 "HelloWorld"。然後我們呼叫了 lcfirst()
函式來將字串的首字母轉換為小寫。最後,我們將轉換後的字串儲存在變數 $result
中,並使用 echo
語句將其輸出到螢幕上。輸出結果為 "helloWorld"。