$my_str="Hello welcome to plus2net.com";
$my_str=strtoupper($my_str);
echo $my_str;
Above code output will be
HELLO WELCOME TO PLUS2NET.COM
Syntax
$val=strtoupper($input_sting);
We can use strtoupper() function in PHP to change all the alphabetic characters to uppercase. This simple function takes one string as input and changes the characters present inside to uppercase.
When comparing user input, converting both inputs to uppercase ensures case-insensitivity:
$input = "hello";
if (strtoupper($input) === strtoupper("HELLO")) {
echo "Inputs match!";
}
For handling multibyte characters, use *mb_strtoupper()* instead:
$str = "élève";
echo mb_strtoupper($str); // Outputs: ÉLÈVE
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.