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.
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!Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
