PHP String ucfirst() FunctionThe 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: Related functions
SyntaxThe syntax of the ucfirst() function is given below that contains only one string parameter. The ucfirst() returns the converted string. Parameter$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. Return ValuesThe ucfirst() function returns the converted string, where the first character of the string is converted to uppercase. ExamplesThere are some examples given, through which we can learn the working of the ucfirst() function. Let's see the below examples- Example 1 Output: 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 Example 2 Output: Hey! are you Aparna Garg? No, I'm Gunjan Garg. Next TopicPHP String Functions |