PHP Case Conversion

In PHP, string-related functions are most popular and widely used while programming. Among them, some set predefined string functions are used for working with string cases.

These functions are used to convert the string case from one another, and also, used to specify a particular string with camel case representation. Such kind of PHP functions is listed below.

    • strtoupper() – To convert string case into uppercase letters.
    • strtolower() – To convert string case into lowercase letters.
    • ucfirst() – To convert the first letter of the string to uppercase letters.
    • ucwords() – To convert the first letter of each word in the string to uppercase letters.

Example: PHP Case Conversion

<?php
$str = "welcome to PHPPOT";
// Output: WELCOME TO PHPPOT
echo $uppercase = strtoupper($str);
// Output: welcome to phppot
echo $lowercase = strtolower($str);
// Output: Welcome to PHPPOT
echo $uppercaseFirst = ucfirst($str);
// Output: Welcome To PHPPOT
echo $uppercaseWord = ucwords($str);
?>
Photo of Vincy, PHP developer
Written by Vincy Last updated: July 2, 2022
I'm a PHP developer with 20+ years of experience and a Master's degree in Computer Science. I build and improve production PHP systems for eCommerce, payments, webhooks, and integrations, including legacy upgrades (PHP 5/7 to PHP 8.x).

Leave a Reply

Your email address will not be published. Required fields are marked *

Explore topics
Need PHP help?