PHP lcfirst Function | String First Character Lowercase

The PHP lcfirst is an inbuilt function in PHP. It takes a string as the parameter and converts the first character lowercase. Also, it doesn’t change other characters of the string. In this article, we will discuss the PHP lcfirst Function. Also, we will discuss a few examples of using it.

To convert the first character of the string to uppercase, you should use PHP ucfirst Function.

Syntax

lcfirst($string)

Parameters

The PHP lcfirst function expects only one parameter. The string whose first character will be changed to lowercase is passed as the parameter.

Return Value

The function returns the string after converting it’s first character to lowercase. However, it does not change other characters. If the first character is already in lowercase, it returns the string as it is.

Input: lcfirst('CONCATLY')
Output: cONCATLY
PHP lcfirst function | convert first character of string to lowercase

Example

<?php

	$string = 'Hello world';
	$newString = lcfirst($string);

?>
OUTPUT:
hello world

In the above example, you can observe that the function converts the first character of the string to lowercase. It does not change any other character of the string.

Conclusion

In this article, we discussed the PHP lcfirst. It converts the first character of the string to lowercase, without effecting any other characters. You can read more about it on PHP Official Documentation. Also, you can read about more PHP String Functions on Concatly.

Spread the Knowledge

Leave a Reply

Your email address will not be published. Required fields are marked *