PHP 8 reference · String Functions
PHP lcfirst() Function
Make the first character of a string lowercase, leaving the rest unchanged. Handy for turning PascalCase into camelCase.
PHP 8 Since 5.3
Syntax
lcfirst(string $string): string
Parameters
| Parameter | Description |
|---|---|
string |
The input string. |
Return value
The string with its first character lowercased.
Examples
<?php
echo lcfirst("HelloWorld"), "\n";
echo lcfirst("ABC"), "\n";
Output
helloWorld aBC
<?php
$class = "UserProfile";
echo lcfirst($class) . "Service", "\n";
Output
userProfileService
Version history
| Version | Change |
|---|---|
| PHP 5.3 | Added |
Related
ucfirst()· Make the first character of a string uppercase and leave the rest as it is. Only ASCII letters change.strtolower()· Convert every ASCII letter in a string to lowercase. Since PHP 8.2 it ignores the locale; use mb_strtolower() for é, Ü and others.- PHP Strings · tutorial