Strtoupper() Function in PHP 8.2, PHP 8.3 & PHP 8.4

The `strtoupper()` function in PHP converts a string to uppercase. It’s a simple but useful string manipulation function that works the same way in PHP 8.PHP 8.1 PHP 8.2 PHP 8.3 PHP and PHP 8.4 as in previous versions.

Basic Syntax

<?php
strtoupper(string $string): string
?>

Example Usage

<?php
$original = "Hello, World!";
$uppercase = strtoupper($original);
echo $original; // Outputs: Hello, World!
echo $uppercase; // Outputs: HELLO, WORLD!
?>

Multibyte Considerations

<?php
$text = "café à Paris
echo strtoupper($text); // Outputs: CAFé à PARIS (incorrect)
echo mb_strtoupper($text); // Outputs: CAFÉ À PARIS (correct)
?>

Practical Example

<?php
// Case-insensitive comparison
$userInput = "yes";
if (strtoupper($userInput) === "YES") {
echo "User confirmed!";
} else {
echo "User did not confirm.";
}
// Converting database fields for display
$productName = "wireless headphones";
echo "PRODUCT: " . strtoupper($productName);
?>

Remember that `strtoupper()` is locale-dependent, so its behavior might change based on the current locale setting for character classification.# Using `strtoupper()` in PHP 8.2

 

strrev() Function in PHP 8.2, PHP 8.3 & PHP 8.4

PHP’s `strrev()` function flips a string. This straightforward built-in function functions in PHP 8.2 in the same manner as it did in earlier iterations.This is how PHP 8, PHP 8.1, PHP 8.2, PHP 8.3, and PHP 8.4 operate.
Read More

strlen() Function in PHP 8.2, PHP 8.3 & PHP 8.4

The `strlen()` function in PHP returns the length of a given string. It’s a fundamental string operation that counts the number of bytes (not necessarily characters) in the string.Here’s how it works in PHP 8, PHP 8.1, PHP 8.2, PHP 8.3 and PHP 8.4.

Read More

trim() Function in PHP 8.2, PHP 8.3 & PHP 8.4

The trim() function in PHP removes whitespace and other predefined characters from both sides of a string.Here’s how it works in PHP 8, PHP 8.1, PHP 8.2, PHP 8.3 and PHP 8.4. Read More

wordwrap() Function in PHP 8.2, PHP 8.3 & PHP 8.4

The wordwrap() function in PHP wraps a string to a given number of characters using a string break character. Here’s how it works in PHP 8, PHP 8.1, PHP 8.2, PHP 8.3 and PHP 8.4. Read More