Changing The Case Of String In PHP

Sometimes, we make variable which has the value of string and we don't really care whether we type it in small or capital letters.
What if we want to change the case of string without changing the string itself?

There are certain codes or commands in PHP which could do just like we want. Please take a look to the coding below. Explanation is in the coding.

<?php
$sentence="What a nice day";
echo strtolower($sentence); //converts string to lowercase
echo "<br>";
echo strtoupper($sentence); //converts string to uppercase
echo "<br>";
echo ucfirst($sentence); //uppercases the first character in string
echo "<br>";
echo ucwords($sentence); //uppercases the first character of all words in string
echo "<p>";
?>

Copy and paste the coding above and you will see how it works. You can also use PHP online compiler HERE. Good Luck!

Labels: , , , , , , , , ,