PHP provides two commonly used string functions, strtolower() and strtoupper(), that allow you to convert a string to lowercase or uppercase. These functions are helpful when you need to standardize or compare strings without being case-sensitive.
strtolower() converts all alphabetic characters in a string to lowercase.strtoupper() converts all alphabetic characters in a string to uppercase.Both functions accept a string as input and return a transformed version of that string.
strtolower(string $text): stringstrtoupper(string $text): string
// Convert an uppercase string to lowercase
<?php
$string = "HELLO WORLD";
$lowercase = strtolower($string);
echo $lowercase;
?>
hello world
// Convert a lowercase string to uppercase
<?php
$string = "hello world";
$uppercase = strtoupper($string);
echo $uppercase;
?>
HELLO WORLD
This flow shows how PHP transforms text internally:
Input String ➜ strtolower() ➜ lowercase text
Input String ➜ strtoupper() ➜ uppercase text
strtolower() for comparisons to avoid case mismatch.strtoupper() for visual emphasis such as labels or headings.mb_strtolower() and mb_strtoupper().