How to Make a String Lowercase or Uppercase in PHP
Sometimes all characters in a string need to be changed from uppercase to lowercase and visa versa. Fortunately, PHP has built-in functions for changing the case of characters in both directions.
To Lowercase Using strtolower()
To convert a string to lower case in PHP use the strtolower()
function. Pass the string to lowercase inside the ()
(parenthesis) - this can be a variable or the string itself.
strtolower("mIxEd CASE TeXt.");
mixed case text.
To Uppercase Using strtoupper()
To convert every character of a string to uppercase use the strtoupper()
function. It accepts one parameter, the string/variable to uppercase.
strtoupper("mIxEd CASE TeXt.");
MIXED CASE TEXT.
Conclusion
You now know how to change the case of every character in a string to uppercase or lowercase using PHP.
string
character
case