PHP ucfirst() function

The ucfirst() function is used for the first character of a string to uppercase.

Syntax

ucfirst ( string $string ) : string

Parameters

Parameter Name Descrption
$string Required, The input string.

Return Value

Returns the converted string.

ucfirst() examples : Convert the first character of "test" to uppercase

$string = 'test string';
$string = ucfirst($string); 
echo $string;
//Test string

$string = 'TEST STRING';
$string = ucfirst($string);  
echo $string; 
//TEST STRING

Related Functions