Skip to content
PHP lcfirst() Function: Description, Parameters, Return Value, and Examples

PHP lcfirst() Function: Description, Parameters, Return Value, and Examples

This article explains PHP's lcfirst() function, which lowercases the first character of a string, details its parameter and return value, and provides code examples demonstrating its behavior with different input strings and locale considerations.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community

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

It returns the input string with its first character converted to lowercase if it is a letter, respecting the current locale.

Parameter: $str – the input string.

Return value: the transformed string.

Example usage:

<?php
$foo = 'HelloWorld';
$foo = lcfirst($foo);
echo $foo; // helloWorld

$bar = 'HELLO WORLD!';
$bar = lcfirst($bar);
echo $bar; // hELLO WORLD!

$bar = lcfirst(strtoupper($bar));
echo $bar; // hELLO WORLD!
?>

Output:

// helloWorld
// hELLO WORLD!
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Tutorialstring-functionslcfirst
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.