PHP strtolower() Function

Usage — The PHP strtolower() function is used to make a string lowercase. This function is binary-safe.

It has the following syntax:

PHP

string strtolower ( string $string )

Here is an example of using strtolower():

PHP

// Output — i ate 3 pies today!
echo strtolower("I ate 3 PieS tOday!");

Return Value — This function returns a string with all alphabetic characters converted to lowercase.

Additional Information — Please keep in mind that ‘alphabetic’ is determined by the current locale. This means that e.g. in the default “C” locale, characters such as umlaut-A (Ä) will not be converted.

PHP Version and Changelog — The strtolower() function is available in PHP 4, PHP 5, PHP 7.

Relevant Functions — Other related PHP functions that you should know about are: strtoupper() which makes a string uppercase, ucfirst() which makes a string’s first character uppercase, ucwords() which makes the first character of each word in a string uppercase and mb_strtolower which makes a string lowercase.

Go Directly To — usage, parameters, working examples or additional tips.

Parameters

string

The string parameter is used to specify the input string. This is a required parameter.

Working Examples

Here are some examples of using the strtolower() function:

PHP

$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtolower($str);

// Output — mary had a little lamb and she loved it so
echo $str;

Additional Tips

Here are some of the most upvoted tips taken from the comment section of the PHP manual:

  1. The function strtolower() doesn’t work for polish chars.

    PHP

    // Output — mĄka
    echo strtolower("mĄkA");
    

    The best solution is to use use the mb_strtolower function.

    PHP

    // Output — mąka
    echo mb_strtolower("mĄkA",'UTF-8');
    

    Suggested by - marcin at maydesign dot pl

  2. It is worth noting that

    PHP

    // Output — string(0) ""
    var_dump(strtolower(null))
    

    Suggested by - helvete at bahno dot net

Further Reading

  1. You can read more about the PHP strtolower() function on PHP.net.

Reader Comments

1. You can register or login to post a comment. Asking readers to register improves the quality of discussion.

2. As a registered user, you will also get to access features like choosing between a light and dark theme or anything else that we might implement in future.

Follow Us For Updates

FacebookTwitterGoogle+
Go To Top