PHP strtoupper() Function
The strtoupper() function converts all alphabetic characters in a string to uppercase.
Syntax
strtoupper(string $string): string
Parameters
| Parameter | Type | Description |
|---|---|---|
$string | string | The input string |
Return Value
Returns the string with all alphabetic characters converted to uppercase.
Try It Online
Output
Click Run to execute your code
More Examples
Format Headers
<?php
$title = "welcome to php";
echo strtoupper($title);
// "WELCOME TO PHP"
?>
ucfirst and ucwords
<?php
$str = "hello world";
echo ucfirst($str); // "Hello world"
echo ucwords($str); // "Hello World"
?>
Note: For UTF-8 strings, use
mb_strtoupper() instead.
Common Use Cases
- Formatting headings
- Product codes and SKUs
- Acronym generation
- Constants display
Related Functions
- strtolower() - Convert to lowercase
ucfirst()- Capitalize first letterucwords()- Capitalize each wordmb_strtoupper()- UTF-8 safe version
Enjoying these tutorials?