How to Convert a String to Lowercase in PHP

09/07/2021

Contents

In this article, you will learn how to convert a string to lowercase in PHP.

PHP strtolower() Function

You can use the strtolower() function in PHP to convert a string to lowercase. The function returns the lowercase version of the input string.

Syntax:
strtolower($string);
Parameters:

$string: The input string that you want to convert to lowercase. It is a required parameter.

Example:
<?php
  $string = "HELLO, WORLD!";
  $lowercase = strtolower($string);
  echo $lowercase; 
?>

The output of the above code will be:

hello, world!

In this example, $string is the original string that we want to convert to lowercase. The strtolower() function is applied to $string and the result is stored in the $lowercase variable. Finally, we use the echo statement to print the lowercase string to the screen.