PHP String ucfirst() Function
The ucfirst() function is used to convert the first character of the string into the uppercase. It is an in-built function of PHP, which takes a string as input and converts only the first letter of that string to uppercase. This function converts only the first character of the string to uppercase and others remains unchanged.
Note: PHP 4+ versions support this function.
There are some related functions in PHP which are similar to the strtolower() function:
The syntax of the ucfirst() function is given below that contains only one string parameter.
The ucfirst() returns the converted string.
$string (required) - It is a mandatory parameter of this function, which specifies the input string. It is the only argument, passed in the ucfirst() function.
The ucfirst() function returns the converted string, where the first character of the string is converted to uppercase.
There are some examples given, through which we can learn the working of the ucfirst() function. Let's see the below examples-
As we can see in the below output that the ucfirst() converts only the first character of the string to uppercase.
Hey! myself shivani garg
Hey! are you Aparna Garg? No, I'm Gunjan Garg.