Home >Backend Development >PHP Tutorial >Summary of PHP English letter case conversion function_PHP tutorial
Convert the first letter of each word to uppercase: ucwords()
$bar = 'HELLO WORLD!';
$bar = ucwords($bar); // HELLO WORLD!
$bar = ucwords(strtolower($bar)); // Hello World!
?>
The first letter of the first word is capitalized: ucfirst()
$bar = 'HELLO WORLD!';
$bar = ucfirst($bar); // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>
Change the first letter of the first word to lowercase: lcfirst()
$bar = 'HELLO WORLD!';
$bar = lcfirst($bar); // hELLO WORLD!
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
?>
Change all letters to uppercase: strtoupper()
Change all letters to lowercase: strtolower()