How to Convert a String to Lowercase in PHP



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.


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

  $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.