What is the lcfirst() function in PHP?

In PHP, the lcfirst() function makes the first character of a string lowercase.

The following figure shows a visual representation of the lcfirst() function.

Figure 1: Visual representation of lcfirst() function

Syntax


lcfirst(str)

Parameter

As a parameter, the lcfirst() function requires a string whose first character is to be converted to lowercase.

Return value

The lcfirst() function lowercases the first character of a string.


  • The rest of the string i.e., except the first character, stays the same.
  • If the first character is not a letter, then the entire string remains same.

Code

The code below shows how the lcfirst() function works.

<?php
#string
echo("lcfirst('EDUCATIVE'): ");
echo (lcfirst('EDUCATIVE'));
echo("\n");
#string with number
echo("lcfirst('EDUCAtIVE09'): ");
echo (lcfirst('EDUCAtIVE09'));
echo("\n");
echo("lcfirst('09EDUCAtIVE'): ");
echo (lcfirst('09EDUCAtIVE'));
?>

Free Resources