The first letter of each word is converted to uppercase: Ucwords ()
The code is as follows: <?php
$foo = ' Hello world! ';
$foo = Ucwords ($foo); Hello world!
$bar = ' HELLO world! ';
$bar = Ucwords ($bar); HELLO world!
$bar = Ucwords (Strtolower ($bar)); Hello world!
?>
First word capitalized: Ucfirst ()
The code is as follows: <?php
$foo = ' Hello world! ';
$foo = Ucfirst ($foo); Hello world!
$bar = ' HELLO world! ';
$bar = Ucfirst ($bar); HELLO world!
$bar = Ucfirst (Strtolower ($bar)); Hello world!
?>
First word initial lowercase: lcfirst ()
The code is as follows: <?php
$foo = ' HelloWorld ';
$foo = Lcfirst ($foo); HelloWorld
$bar = ' HELLO world! ';
$bar = Lcfirst ($bar); HELLO world!
$bar = Lcfirst (Strtoupper ($bar)); HELLO world!
?>
All letters capitalized: Strtoupper ()
All Letters lowercase: strtolower ()
- 1 strtolower ()//convert string to lowercase
- 2 Strtoupper ()//convert string to uppercase
- 3 Ucfirst ()//converts the first character of a string to uppercase
- 4 ucwords ()//converts the first letter of each word in a string to uppercase
PHP English Letter case Conversion Function Summary