PHP strtolower() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
String

Definition

In PHP, strtolower() converts every letter in a string to lowercase.

It returns a new string and leaves the original unchanged.

Syntax

Call strtolower() with the values you need. Start with this line.

PHP
$lower = strtolower($text);
CallWhat it does
strtolower("Hello WORLD")Returns "hello world".
strtolower("PHP 8.3")Returns "php 8.3". Digits and symbols stay the same.

Since PHP 8.2, strtolower() only changes ASCII letters (A to Z) and no longer depends on the locale. Use mb_strtolower() for accented or non-English text.

Library declarations
PHP
strtolower(string $string): string

Parameters

ParameterDescription
stringRequired. The input string.

Return Value

Return ValueDescription
stringThe string with all ASCII letters converted to lowercase.

PHP Examples

Example 1 — Convert Text to Lowercase

Pass any string and get a lowercase copy.

PHP
<?php
$text = "Hello WORLD";
$lower = strtolower($text);

echo $lower, PHP_EOL;
echo $text, PHP_EOL;

How It Works

  1. Create a string. It has a mix of upper and lower case letters.
  2. Call strtolower(). It returns a lowercase copy.
  3. Print the copy. You see hello world.
  4. Original is safe. $text still has its original case.

Example 2 — Digits and Symbols Stay Put

Only letters change. Everything else is left alone.

PHP
<?php
echo strtolower("PHP 8.3 IS GREAT!"), PHP_EOL;
echo strtolower("already lower"), PHP_EOL;
echo strtolower("123-ABC"), PHP_EOL;

How It Works

  1. Letters change. PHP becomes php.
  2. Numbers stay. 8.3 and 123 are not affected.
  3. Symbols stay. The ! and - are untouched.
  4. Already lowercase. The text comes back the same.

Example 3 — Case-Insensitive Comparison

Lowercase both values before comparing them, for example two email addresses.

PHP
<?php
$a = "[email protected]";
$b = "[email protected]";

if (strtolower($a) === strtolower($b)) {
    echo "Same email", PHP_EOL;
} else {
    echo "Different email", PHP_EOL;
}

How It Works

  1. Two values. They differ only in letter case.
  2. Normalize both. strtolower() makes them identical.
  3. Compare strictly. === now returns true.
  4. Alternative. strcasecmp() can compare without creating copies.

Frequently Asked Questions

strtolower() converts all letters in a string to lowercase and returns the new string.
string strtolower(string $string). It takes one required argument and returns a string.
No. It returns a new string. Assign the result to a variable if you want to keep it.
Not reliably. Since PHP 8.2 it only converts ASCII letters. Use mb_strtolower() for UTF-8 text such as accented letters.
Use strtoupper() to convert every letter to uppercase, or ucfirst() and ucwords() to capitalize only the first letters.

Next: strtoupper()

strtoupper() converts every letter in a string to uppercase.

strtoupper() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful