Home >Backend Development >PHP Tutorial >PHP converts the first character in a string to lowercase using the lcfirst() function

PHP converts the first character in a string to lowercase using the lcfirst() function

黄舟
黄舟Original
2017-11-02 13:05:221301browse

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 = &#39;HelloWorld&#39;;
$foo = lcfirst($foo);             // helloWorld

$bar = &#39;HELLO WORLD!&#39;;
$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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn