PHP String strtolower() function

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.

Note: The strtolower () is a binary-safe function.

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

Related functions

  • strtolower() - 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.

Syntax

The syntax for the strtolower() function is given below, which takes only one string parameter.

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.

Examples

The strtolower() is a widely used function of PHP. Below some examples are given. With the help of these examples, we can understand the working of this function practically.

Example 1

Output:

all is well

Example 2

Output:

String before conversion: ALAYMA IS A CUTE AND SINCERE GIRL.
String after conversion: alayma is a cute and sincere girl.

Example 3

In this example, we will see that special characters remain the same after applying strtolower() function on the string. It only converts alphabet characters, whereas there is no change in special symbols.

Output:

String before conversion: !, @, %, $, And # Are The Special Symbols.
String after conversion: !, @, %, $, and # are the special symbols.





Latest Courses