Usage — The PHP
strtolower() function is used to make a string lowercase. This function is binary-safe.
It has the following syntax:
string strtolower ( string $string )
Here is an example of using
// 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.
string parameter is used to specify the input string. This is a required parameter.
Here are some examples of using the
$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;
Here are some of the most upvoted tips taken from the comment section of the PHP manual:
strtolower()doesn’t work for polish chars.
// Output — mĄka echo strtolower("mĄkA");
The best solution is to use use the
// Output — mąka echo mb_strtolower("mĄkA",'UTF-8');
Suggested by - marcin at maydesign dot pl
It is worth noting that
// Output — string(0) "" var_dump(strtolower(null))
Suggested by - helvete at bahno dot net
- You can read more about the PHP strtolower() function on PHP.net.
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.