In this article, I am going to explain how to use the built-in functions for uppercase, lowercase and camelcase in PHP. PHP has many built-in functions. Some of the functions are listed below.
Using the strtoupper() PHP function to convert all the letters into uppercase. The example is given below.
<?php
$string_uppercase = "Conversion all uppercase";
echo strtoupper($string_uppercase);
?>
Output: CONVERSION ALL UPPERCASE
The strtolower() PHP function is used to convert all the letters to lowercase. The example is given below.
<?php
$str_lower = "Convert All Small Letters using strtolower PHP functions";
echo strtolower($str_lower);
?>
Output: convert all small letters using strtolower php functions
Make the first letter of each word in the given string capital by using the ucwords() PHP function. The example below:
<?php
$str_first_capital = "first letter capital of each word";
echo ucwords($str_first_capital);
?>
Output: First Letter Capital Of Each Word
Only the first letter of the provided text is capitalized when using the ucfirst() function. Be aware that this function only changes the first letter of the string rather than all the sentences if your string contains several sentences.
<?php
$str_first_cap = "first letter capital in php function";
echo ucfirst($str_first_cap);
?>
Output: First letter capital in php function
<?php
$str_first_low = "First letter lowercase in php function";
echo ucfirst($str_first_low);
?>
Output: first letter lowercase in PHP function