How to convert lowercase string to uppercase using PHP ?
In PHP, we can convert a lowercase string to uppercase using the strtoupper()
function. This function takes a string as input and returns the uppercase version of the string.
Here's an example:
$lowercaseString = "hello world";
$uppercaseString = strtoupper($lowercaseString);
echo $uppercaseString; // Output: HELLO WORLD
Another way to convert a lowercase string to uppercase is by using the mb_strtoupper()
function. This function is similar to strtoupper()
, but it supports multi-byte characters.
Here's an example:
$lowercaseString = "こんにちは世界";
$uppercaseString = mb_strtoupper($lowercaseString, 'UTF-8');
echo $uppercaseString; // Output: こんにちは世界
In this example, we used the mb_strtoupper()
function to convert a string containing Japanese characters to uppercase. We specified the character encoding as UTF-8
to ensure that the function works correctly with multi-byte characters.