PHP 8 reference · Multibyte String Functions

PHP mb_ucfirst() Function

Make the first character of a string title case, including letters such as é or ı. Added in PHP 8.4.

PHP 8 Since 8.4

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

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

Parameters

ParameterDescription
string The input string.
encoding optional The character encoding; defaults to mb_internal_encoding() (UTF-8).

Return value

The string with its first character in title case.

Examples

Accented first letter
<?php
echo ucfirst("élan"), "\n";
echo mb_ucfirst("élan"), "\n";

Output

élan
Élan

Run this on your computer — see “Get Started” for setup.

mb_lcfirst() does the opposite
<?php
echo mb_lcfirst("Ärger"), "\n";

Output

ärger

Run this on your computer — see “Get Started” for setup.

Version history

VersionChange
PHP 8.4Added

In other languages

Was this page helpful?