PHP mb_strtoupper() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
mbstring

Definition

In PHP, mb_strtoupper() changes every letter in a string to uppercase, including accented letters and other scripts.

Plain strtoupper() only handles basic English letters, so use this one for UTF-8 text.

Syntax

Call mb_strtoupper() with the values you need. Start with this line.

PHP
$upper = mb_strtoupper($text, "UTF-8");
CallWhat it does
mb_strtoupper("café", "UTF-8")Returns "CAFÉ".
mb_strtoupper("hello", "UTF-8")Returns "HELLO".

Some letters become two. In PHP 7.3 and later, ß becomes SS.

Library declarations
PHP
mb_strtoupper(string $string, ?string $encoding = null): string

Parameters

ParameterDescription
stringRequired. The text to change.
encodingOptional. The character encoding. Default is the internal encoding.

Return Value

Return ValueDescription
stringThe text with every letter in uppercase.

PHP Examples

Example 1 — Uppercase Accented Text

Compare strtoupper() with mb_strtoupper().

PHP
<?php
$text = "café au lait";

echo strtoupper($text), PHP_EOL;
echo mb_strtoupper($text, "UTF-8"), PHP_EOL;

How It Works

  1. Use a phrase with an accented letter.
  2. strtoupper() only changes plain ASCII letters, so é stays.
  3. mb_strtoupper() changes é to É.
  4. Use the multibyte version for UTF-8 text.

Example 2 — See ß Become SS

The German letter ß has no single uppercase letter, so it becomes two.

PHP
<?php
$word = "straße";

echo mb_strtoupper($word, "UTF-8"), PHP_EOL;
echo mb_strlen($word, "UTF-8"), " -> ", mb_strlen(mb_strtoupper($word, "UTF-8"), "UTF-8"), PHP_EOL;

How It Works

  1. Use a word with the letter ß.
  2. It becomes SS in uppercase.
  3. The word grows from 6 to 7 characters.
  4. This is the full Unicode rule, used in PHP 7. 3 and later.

Example 3 — Uppercase Another Script

The function also works for Cyrillic and Greek letters.

PHP
<?php
echo mb_strtoupper("привет", "UTF-8"), PHP_EOL;
echo mb_strtoupper("αβγ", "UTF-8"), PHP_EOL;

How It Works

  1. The first line uses Cyrillic letters.
  2. The second line uses Greek letters.
  3. Each letter is replaced by its capital.
  4. Pass UTF-8 so the script is read correctly.

Frequently Asked Questions

mb_strtoupper() converts a string to uppercase and handles accented letters and non-English scripts.
mb_strtoupper(string $string, ?string $encoding = null): string.
strtoupper() only changes basic ASCII letters. mb_strtoupper() changes letters in every script it knows.
Unicode has no capital for ß in this rule, so full case mapping uses SS. PHP follows it since version 7.3.
mb_strtolower() makes every letter lowercase.

Next: mb_substr()

mb_substr() returns part of a string by character position.

mb_substr() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful