When it comes to altering the case of a string, PHP makes it easy with four built-in functions. Two of them are illustrated previously: the strtoupper() function uppercases all the characters in a string, while the strtolower() function lowercases all the characters in a string.
For more precise control, consider the ucfirst() function, which capitalizes the first character of a string (good for sentences), and the ucwords() function, which capitalizes the first character of every word in the string (good for titles).
Here’s an example:<?php // define string $rhyme = "and all the king's men couldn't put him together again"; // uppercase first character of string // result: "And all the king's men couldn't put him together again" $ucfstr = ucfirst($rhyme); echo $ucfstr; // uppercase first character of every word of string // result: "And All The King's Men Couldn't Put Him Together Again" $ucwstr = ucwords($rhyme); echo $ucwstr; ?>