Learn about the case conversion function in php. String-related methods are widely used during programming.
In this short tutorial, we show you some predefined string case conversion functions.
These functions are used to convert a string case to another like in uppercase letters, lowercase letter,s etc.
PHP Case Conversion Functions:
- strtolower() – It converts string case into lowercase letters.
- strtoupper() – It converts string case into uppercase letters.
- ucfirst() – It converts the first letter of the string to uppercase letters.
- ucwords() – It converts the first letter of each word in the string to uppercase letters.
String Case Conversion Function Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$string = "learn PHP programming"; echo $uppercase = strtoupper($string); //Output: LEARN PHP PROGRAMMING echo $lowercase = strtolower($string); //Output: learn php programming echo $uppercaseFirst = ucfirst($string); //Output: Learn PHP programming echo $uppercaseWord = ucwords($string); //Output: Learn PHP Programming |