Example
Convert the first character of "Hello" to lowercase. :
<?php echo lcfirst("Hello world!"); ?>
Definition and usage
lcfirst() function converts the first character in the string to lowercase.
Related functions:
ucfirst() - Convert the first character in the string to uppercase.
ucwords() - Converts the first character of each word in the string to uppercase.
strtoupper() - Convert a string to uppercase.
strtolower() - Convert a string to lowercase.
Syntax
lcfirst(string)
Parameter Description
string Required. Specifies the string to be converted.
Technical details
Return value: Returns the converted string.
PHP Version: 5.3.0+
Example:
<?php $foo = 'HelloWorld'; $foo = lcfirst($foo); // helloWorld $bar = 'HELLO WORLD!'; $bar = lcfirst($bar); // hELLO WORLD! $bar = lcfirst(strtoupper($bar)); // hELLO WORLD! ?>
The above is the detailed content of PHP converts the first character in a string to lowercase using the lcfirst() function. For more information, please follow other related articles on the PHP Chinese website!