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

黄舟
Release: 2023-03-16 22:16:02
Original
1270 people have browsed it

Example

Convert the first character of "Hello" to lowercase. :

<?php
echo lcfirst("Hello world!");
?>
Copy after login

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)
Copy after login

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!
?>
Copy after login


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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template