Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

PHP | lcfirst() Function

  • Last Updated : 11 Apr, 2018

The lcfirst() function is a built-in function in PHP which takes a string as an argument and returns the string with the first character in Lower Case and all other characters remain unchanged.



Parameter: The function accepts only one parameter $string which is mandatory. This parameter represents the input string whose first character will be changed to lowercase.

Return Value: The function returns the same string only by changing the first character to lower case of the passed argument $string.


Input : "Geeks for geeks"
Output : geeks for geeks

Input : "chetna agarwal"
Output : chetna agarwal

Below programs illustrate the lcfirst() function in PHP:

Program 1:

    // PHP program to demonstrates the 
    // use of lcfirst() function 
    $str = "Geeks for geeks";
    // converts the first character to 
    // lower case and prints the string


geeks for geeks

Program 2: The program below demonstrates the use of lcfirst() function when the starting character is already in lower-case.

    // PHP program that demonstrates the 
    // use of lcfirst() function when 
    // the first case is already in lowercase
    $str = "chetna agarwal";
    // already the first character is in lower case 
    // so prints the same string only


chetna agarwal


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!