Menu Close

How to convert a string to lowercase in PHP?

How to convert a string to lowercase in PHP?

The strtolower() is one of the most popular functions of PHP, which is widely used to convert the string into lowercase. It takes a string as a parameter and converts all uppercase English character of that string to lowercase. Other characters such as numbers and special character of that string remain the same. PHP 4+ versions support this function.

Hint: Use the PHP strtolower() function

Syntax

strtolower($string) 

Parameters

$string (required): This is a mandatory parameter of this function which specifies a string to convert into lowercase. In simple words – it is a string which is converted into lowercase.

Return Value

It returns converted lowercase string.

Example

You can use the PHP strtolower() function to convert a string to lowercase. Let’s check out the following example to understand how this function actually works:

<?php
$my_str = 'Learn, Share and Grow Your Coding Skills';
echo strtolower($my_str);
?> 

Output

learn, share and grow your coding skills 

There are some other functions in PHP which are similar to the strtolower() function:

Related PHP functions

  • strtoupper() – It converts a string into uppercase.
  • lcfirst() – It converts the first character of a string into lowercase.
  • ucfirst() – It converts the first character of a string into uppercase.
  • ucwords() – It converts the first character of each word in a string into uppercase.
Posted in PHP

You can also read...