mb_strtoupper

(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)

mb_strtoupperConvierte todos los caracteres a mayúsculas

Descripción

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

Devuelve el string string después de convertir todos los caracteres alfabéticos a mayúsculas.

Parámetros

string

El string a convertir a mayúsculas.

encoding

The encoding parameter is the character encoding. If it is omitted or null, the internal character encoding value will be used.

Valores devueltos

Devuelve el string string con todos los caracteres convertidos a mayúsculas.

Ejemplos

Ejemplo #1 Ejemplo con mb_strtoupper()

<?php
$str
= "Marie A Un Petit Agneau Et Elle L'Aime BEAUCOUP.";
$str = mb_strtoupper($str);
echo
$str; // MARIE A UN PETIT AGNEAU ET ELLE L'AIME BEAUCOUP.
?>

Ejemplo #2 Ejemplo con mb_strtoupper() y texto UTF-8 no latino

<?php
$str
= "Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός";
$str = mb_strtoupper($str, 'UTF-8');
echo
$str; // Muestra ΤΆΧΙΣΤΗ ΑΛΏΠΗΞ ΒΑΦΉΣ ΨΗΜΈΝΗ ΓΗ, ΔΡΑΣΚΕΛΊΖΕΙ ΥΠΈΡ ΝΩΘΡΟΎ ΚΥΝΌΣ
?>

Notas

A diferencia de strtoupper(), el concepto de carácter 'alfabético' se determina por las propiedades Unicode. Por lo tanto, el comportamiento de esta función no se modifica por las configuraciones locales, y puede convertir todos los caracteres considerados alfabéticos como la c cedilla (ç).

Para más información sobre las propiedades de Unicode, véase » http://www.unicode.org/reports/tr21/.

Ver también

add a note

User Contributed Notes 1 note

up
6
serg_x
5 years ago
Only first letter

function mb_ucfirst($string, $encoding = 'UTF-8'){
$strlen = mb_strlen($string, $encoding);
$firstChar = mb_substr($string, 0, 1, $encoding);
$then = mb_substr($string, 1, $strlen - 1, $encoding);
return mb_strtoupper($firstChar, $encoding) . $then;
}
To Top