Tuesday, June 16, 2026
HomeLanguagesPHP lcfirst() Function

PHP lcfirst() Function

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.

Syntax:

lcfirst($string)

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.

Examples:

Input : "Geeks for neveropen"
Output : neveropen for neveropen

Input : "chetna agarwal"
Output : chetna agarwal

Below programs illustrate the lcfirst() function in PHP:

Program 1:




<?php
    // PHP program to demonstrates the 
    // use of lcfirst() function 
      
    $str = "Geeks for neveropen";
      
    // converts the first character to 
    // lower case and prints the string
    echo(lcfirst($str)); 
?>


Output:

neveropen for neveropen

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




<?php
    // 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
    echo(lcfirst($str)); 
?>


Output:

chetna agarwal

Reference:
http://php.net/manual/en/function.lcfirst.php

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32516 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS