PHP lcfirst() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
String

Definition

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

The rest of the string is left alone. It is the opposite of ucfirst().

Syntax

Call lcfirst() with the values you need. Start with this line.

PHP
$result = lcfirst("Hello World");
CallWhat it does
lcfirst("Hello World")Returns "hello World".
lcfirst("ABC")Returns "aBC". Only the first letter changes.
lcfirst("")Returns an empty string.

lcfirst() only changes the first byte, and only when it is an ASCII letter A to Z.

Library declarations
PHP
lcfirst(string $string): string

Parameters

ParameterDescription
stringRequired. The input string.

Return Value

Return ValueDescription
stringA copy of the string with the first character in lowercase.

PHP Examples

Example 1 — Lowercase the First Letter

Pass a string and get it back with a lowercase first letter.

PHP
<?php
$text = "Hello World";
$result = lcfirst($text);

echo $result, PHP_EOL;

How It Works

  1. Start with a string. It begins with an uppercase H.
  2. Call lcfirst. The first character becomes lowercase.
  3. Rest stays the same. The W in World is still uppercase.
  4. Print the result. The output is hello World.

Example 2 — Edge Cases: Empty and Non-Letters

See what happens with all caps, an empty string, and a digit at the start.

PHP
<?php
echo lcfirst("ABC"), PHP_EOL;
echo "[" . lcfirst("") . "]", PHP_EOL;
echo lcfirst("1st place"), PHP_EOL;

How It Works

  1. All caps input. Only the first letter drops to lowercase, so you get aBC.
  2. Empty string. There is nothing to change, so the result is empty.
  3. Digit first. A digit has no lowercase form, so the string stays the same.
  4. No errors. lcfirst is safe to call on any string.

Example 3 — Turn PascalCase into camelCase

A common use: convert a class-style name into a variable-style name.

PHP
<?php
$className = "UserProfileName";
$variableName = lcfirst($className);

echo $variableName, PHP_EOL;

How It Works

  1. Begin with PascalCase. Every word starts with a capital letter.
  2. Apply lcfirst. Only the first letter is lowered.
  3. Get camelCase. The inner capitals stay, so the words stay readable.
  4. Use it as a name. This is handy for property or variable names.

Frequently Asked Questions

lcfirst() returns a copy of a string with its first character converted to lowercase. The rest of the string is not changed.
string lcfirst(string $string). It takes one required string and returns a new string.
lcfirst() lowercases only the first character. strtolower() lowercases every character in the string.
No. It works on single bytes and only changes ASCII letters. For UTF-8 text, use mb_strtolower() on the first character with mb_substr().
Use ucfirst(). It makes the first character uppercase and leaves the rest alone.

Next: levenshtein()

levenshtein() counts how many single-character edits turn one string into another.

levenshtein() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful