Web Analytics

PHP strtoupper() Function

String Function PHP 4+

The strtoupper() function converts all alphabetic characters in a string to uppercase.

Syntax

strtoupper(string $string): string

Parameters

ParameterTypeDescription
$stringstringThe 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 letter
  • ucwords() - Capitalize each word
  • mb_strtoupper() - UTF-8 safe version