Built-in functions for Uppercase Lowercase in PHP

How to use built-in functions for uppercase, lowercase, and camelcase in PHP?

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.

  • strtoupper() function– For making a PHP string uppercase (the function converts a string to uppercase)
  • strtolower() function – that converts a specified string to lowercase letters.(The function converts a string to lowercase)
  • ucwords() – camel cased i.e. Capitalizes the first letter of each word in a string.
  • cfirst() function – convert the first character of the sentence to uppercase.
  • lfirst () function – convert the first character of the word to lowercase. 

Example:

Uppercase conversion by strtoupper PHP function

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

Convert all small letters using strtolower PHP functions

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

Making the first letter of each word capitalized using ucwords.

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

Making the first letter capital in a string

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

Making the first letter lowercase in a string

<?php
$str_first_low = "First letter lowercase in php function";
echo ucfirst($str_first_low);
?>

Output: first letter lowercase in PHP function

Related Tutorials

  1. Pricing Table Design Bootstrap 5?
  2. How to Display Content on hovering Card using CSS?
  3. How to create a Portfolio Gallery?
  4. FAQ Page with Show and Hide Questions and Answers?
  5. Bootstrap Team Section Design Download
  6. Bootstrap Carousel with Captions and Thumbnails Free Download
  7. Bootstrap Table Search Filter Free Download