VOOZH about

URL: https://www.geeksforgeeks.org/php/php-ucfirst-function/

⇱ PHP ucfirst() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

PHP ucfirst() Function

Last Updated : 11 Jul, 2025
The ucfirst() function is a built-in function in PHP which takes a string as an argument and returns the string with the first character in Upper Case and all other characters remain unchanged. Syntax:
ucfirst($string)
Parameter: The function accepts only one parameter $string which is mandatory. This parameter represents the string whose first character will be changed to uppercase. Return Value: The function returns the same string only by changing the first character to upper case of the passed argument $string. Examples:
Input : "geeks for geeks"
Output : Geeks for geeks

Input : "Chetna Agarwal"
Output : Chetna Agarwal
Below programs illustrate the ucfirst() function in PHP: Program 1: The program below demonstrates the use of ucfirst() function. Output:
Geeks for geeks
Program 2: The program below demonstrates the use of ucfirst() function when the starting character is in upper-case. Output:
Chetna Agarwal
Reference: https://www.php.net/manual/en/function.ucfirst.php
Comment
Article Tags: