Home >Backend Development >PHP Problem >How to convert string to lowercase in php

How to convert string to lowercase in php

青灯夜游
青灯夜游Original
2021-05-17 18:19:204534browse

php method to convert a string to lowercase: 1. strtolower() function, which can convert all letters in the string to lowercase, the syntax is "strtolower (string)"; 2. lcfirst() function , you can convert the first character in the string to lowercase, the syntax is "lcfirst(string)".

How to convert string to lowercase in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

php can change characters Convert string to lowercase

Method 1: Use strtolower() function

strtolower() function to convert string to lowercase.

Syntax:

strtolower(string)

Example:

<?php
echo strtolower("Hello WORLD!");
?>

Output:

hello world!

Method 2: Use lcfirst() function

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

Grammar:

lcfirst(string)

Example:

<?php
echo lcfirst("HELLO WORLD!");
?>

Output:

hello world!

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to convert string to lowercase in php. 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
Previous article:How to call css in phpNext article:How to call css in php