The PHP ucfirst is an inbuilt function in PHP. It takes a string as the parameter and converts the first character uppercase. Also, it doesn’t change other characters of the string. In this article, we will discuss the PHP ucfirst Function. Also, we will discuss a few examples of using it.
To convert the first character of the string to lowercase, you should use PHP lcfirst Function.
Syntax
ucfirst($string)
Parameters
The PHP ucfirst function expects only one parameter. The string whose first character will be changed to uppercase is passed as the parameter.
Return Value
The function returns the string after converting it’s first character to uppercase. However, it does not change other characters. If the first character is already in uppercase, it returns the string as it is.
Input: ucfirst('concatly') Output: Concatly Input: ucfirst('bringing knowledge together') Output: Bringing Knowledge Together

Example
<?php $string = 'hello world'; $newString = ucfirst($string); ?>
OUTPUT:
Hello world
In the above example, you can observe that the function converts the first character of the string to uppercase. It does not change any other character of the string.
Conclusion
In this article, we discussed the PHP ucfirst. It converts the first character of the string to uppercase, without effecting any other characters. You can read more about it on PHP Official Documentation. Also, you can read about more PHP String Functions on Concatly.

Vishesh is currently working as an Intermediate Software Engineer with Orion Health, New Zealand. He graduated with a Masters in Information Technology from the University of Auckland in 2021. With more than 4 years of work experience, his expertise includes Java, Python, Machine Learning, PHP, Databases, Design and Architecture.