In this PHP tutorial, you shall learn how to convert a given string to uppercase using strtoupper() function, with example programs.
PHP – Convert string to uppercase
To convert a string to uppercase in PHP, use strtoupper()
function. Call strtoupper()
and pass the given string as argument.
Syntax
The syntax to convert the string str
to uppercase using strtoupper()
function is
</>
Copy
strtoupper($str);
The function returns a string value with all the characters in the given string converted to uppercase.
Examples
1. Convert string to uppercase
In this example, we will take a string str
that has some lowercase characters. We convert this string to uppercase and print it.
PHP Program
</>
Copy
<?php
$str = 'Hello World';
$output = strtoupper($str);
echo $output;
?>
Output
Conclusion
In this PHP Tutorial, we learned how to convert a string to uppercase, using strtoupper()
function.