The ucfirst Function

The ucfirst function converts the first character of a string to uppercase. Works correctly only with Latin characters (single-byte characters).

Syntax

phpucfirst(string $string): string

Example

Let's convert the first character of the string to uppercase:

php<?php
  echo ucfirst('abcde');
?>

Code execution result:

php'Abcde'

See Also

  • the lcfirst function,
    which converts the first character to lowercase
  • the strtoupper function,
    which converts a string to lowercase
  • the strtolower function,
    which converts a string to uppercase
  • the ucwords function,
    which converts the first letters of words to uppercase