lcfirst() Function in PHP 8.1 and 8.2 With Example

Support PHP Version: PHP 7.1, PHP 7.2, PHP 7.3, PHP 7.4, PHP 8.0, PHP 8.1, PHP 8.2, PHP 8.3 With Latest All Version Support.

Hello Friends Today, through this tutorial, I will tell you How to Use `lcfirst()` function using PHP, PHP 8, PHP 8.1, PHP 8.2 With Example. The `lcfirst()` function in PHP is used to convert the first character of a string to lowercase. This function is available in both PHP 8.1 and PHP 8.2. Here’s how you can use it with an example:

// Example usage of lcfirst() function in PHP 8.1 and 8.2
// Original string
$string = "Hello, World!";
// Convert the first character to lowercase
$lowercased_string = lcfirst($string);
// Output the result
echo $lowercased_string;

In this example, the `lcfirst()` function converts the first character of the string “Hello, World!” to lowercase, resulting in “hello, World!”. The modified string is then stored in the variable `$lowercased_string` and echoed out.

The output will be:

hello, World!

`lcfirst()` is particularly useful when you need to ensure that the first character of a string is lowercase, for example, when formatting output or processing user input.