PHPIntermediate

PHP Case Conversion

PB Pb28 Master Team July 2nd, 2022 Intermediate

📦 Get the complete source code for this tutorial

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
<?php

$str = "welcome to Pb28 Master";

// Output: WELCOME TO Pb28 Master

echo $uppercase = strtoupper($str);

// Output: welcome to Pb28 Master

echo $lowercase = strtolower($str);

// Output: Welcome to Pb28 Master

echo $uppercaseFirst = ucfirst($str);

// Output: Welcome To Pb28 Master

echo $uppercaseWord = ucwords($str);

?>

📦 Download the full project files and try it locally