lcfirst() Function in PHP 8.5

The lcfirst() function in PHP 8.5 converts the first character of a string to lowercase. It only affects ASCII characters in the range "A" (0x41) to "Z" (0x5a) .

Function Signature

lcfirst(string $string): string

It takes the input string and returns the modified string with the first character lowercased .

Example

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

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

Important Note for PHP 8.5

As of PHP 8.2.0, the case conversion no longer depends on the locale set by setlocale(). Only ASCII characters will be converted . This means that for non-ASCII characters (like accented letters or characters from other languages), lcfirst() will not change them to lowercase.

4 Views