Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

mb_strtoupper()

Use mb_strtoupper to uppercase letters using Unicode properties in the specified encoding, or the internal encoding when omitted.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

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

Use mb_strtoupper to uppercase letters using Unicode properties in the specified encoding, or the internal encoding when omitted. It does not depend on the process locale. A mapping may expand one character to several, so output length need not equal input length. An unknown encoding name raises ValueError.

Signature

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

Example output

["STRASSE",6,7]
ValueError

Examples

<?php
$source = "Straße";
$upper = mb_strtoupper($source, "UTF-8");
echo json_encode([$upper, mb_strlen($source, "UTF-8"), mb_strlen($upper, "UTF-8")]), PHP_EOL;
try { mb_strtoupper("a", "not_an_encoding"); } catch (ValueError $e) { echo get_class($e); }

Result

["STRASSE",6,7]
ValueError

Sources