In php, we can make all characters in a string lowercase easily with the php strtolower() function.

$variable = "THIS IS A STRING VARIABLE";

echo strtolower($variable);

//Output:
this is a string variable

When working with string variables in our php programs, it is useful to be able to easily manipulate and change the value of the variables. One such change is if you want to make a string lowercase.

To make all characters in a string lowercase in php, we can use the php strtolower() function.

strtolower() takes in a string and converts all characters to lowercase.

Below is a simple example of how to use the strtolower() function in php to convert a string to lowercase.

$variable = "THIS IS A STRING VARIABLE";

echo strtolower($variable);

//Output:
this is a string variable

Make String Uppercase in php with strtoupper()

We can also make a string uppercase easily in php. The strtoupper() function takes in a string and makes all of the characters uppercase.

Below is an example of how to convert a string uppercase in php with strtoupper()

$variable = "this is a string variable";

echo strtoupper($variable);

//Output:
THIS IS A STRING VARIABLE

Hopefully this article has been useful for you to learn how to make a string lowercase in php.

Categorized in:

PHP,

Last Update: February 26, 2024