Content · Programming · PHP

PHP mb_strtoupper() Function: Usage and Examples

Learn how to convert a Unicode string to uppercase in PHP with syntax, clear code examples, practical use, and common mistakes.

1 views Published Oct 16, 2026 Updated Oct 16, 2026

When working with PHP, you may need to convert a Unicode string to uppercase. This guide explains the operation, shows what its arguments mean, and uses three separate examples to make the result easier to understand.

mb_strtoupper: This applies Unicode uppercase mappings and can expand some characters into multiple code points.

What Is mb_strtoupper in PHP?

Convert a Unicode string to uppercase. This applies Unicode uppercase mappings and can expand some characters into multiple code points.

Syntax:

mb_strtoupper(string $string, ?string $encoding = null): string

Parameters and return value: The signature above identifies the arguments and return type where the API has a single call. For topic guides, follow the sequence of calls in the examples. Always distinguish a returned value from an object or variable modified by reference.

Important: The result may have a different character count. Avoid using uppercase transformation as an immutable identifier.

Example 1: Basic Usage

This example introduces the operation with a short and predictable input.

<?php

echo mb_strtoupper("café", "UTF-8");

The code focuses on the main operation. This applies Unicode uppercase mappings and can expand some characters into multiple code points.

Example 2: Another Case

Now compare a different input, locale, date, or option to see another part of the behavior.

<?php

echo mb_strtoupper("hello", "UTF-8");

What changes? The result may have a different character count. Avoid using uppercase transformation as an immutable identifier.

Practical Example: Applying It in an Application

Use the following separate example as a starting point for a small application task. Check any extension or environment requirements below before running it.

<?php

$labels = ["urgent", "résumé", "complete"];
foreach ($labels as $label) {
    echo mb_strtoupper($label, "UTF-8") . PHP_EOL;
}

The practical example demonstrates how to apply this operation to multiple values, a reusable task, or a validated input. This applies Unicode uppercase mappings and can expand some characters into multiple code points.

Important Behavior and Edge Cases

  • Core behavior: This applies Unicode uppercase mappings and can expand some characters into multiple code points.
  • Inputs and results: The result may have a different character count. Avoid using uppercase transformation as an immutable identifier.
  • Alternatives: mb_strtolower() converts to lowercase and mb_convert_case() supports title case.
  • Compatibility: mbstring is required for mb_* functions.

Comparison With Related Functions

Function or ApproachWhen to Use It
mb_strtoupperConvert a unicode string to uppercase.
Related PHP approachmb_strtolower() converts to lowercase and mb_convert_case() supports title case.

Common Beginner Mistakes

MistakeCorrect Approach
Using an incorrect input or optionThe result may have a different character count. Avoid using uppercase transformation as an immutable identifier.
Confusing this API with a related operationmb_strtolower() converts to lowercase and mb_convert_case() supports title case.
Assuming output is identical across environmentsCheck return values and required extensions or versions. mbstring is required for mb_* functions.

Key Takeaways

  • mb_strtoupper helps you convert a Unicode string to uppercase.
  • This applies Unicode uppercase mappings and can expand some characters into multiple code points.
  • The result may have a different character count. Avoid using uppercase transformation as an immutable identifier.

Use mb_strtoupper when you need to convert a Unicode string to uppercase. Start with the first example, compare the second, and adapt the practical example to your inputs. Confirm the return value and environment requirements before adding it to production code.

Share this resourceSend this page to someone who may find it useful.