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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

lcfirst(string $string): string

Parameters

ParameterDescription
string The input string.

Return value

The string with its first character lowercased.

Examples

Lowercase the first letterTry it yourself
<?php
echo lcfirst("HelloWorld"), "\n";
echo lcfirst("ABC"), "\n";

Output

helloWorld
aBC
PascalCase to camelCaseTry it yourself
<?php
$class = "UserProfile";
echo lcfirst($class) . "Service", "\n";

Output

userProfileService

Version history

VersionChange
PHP 5.3Added

Was this page helpful?