String Functions

PHP ucfirst() Function

Topic: PHP String ReferencePrev|Next


The ucfirst() function converts the first character of a string to uppercase.

The following table summarizes the technical details of this function.

Return Value: Returns the modified string.
Version: PHP 4+


The basic syntax of the ucfirst() function is given with:


The following example shows the ucfirst() function in action.

// Sample string
$str = "hello world!";

// Making string's first character uppercase
echo ucfirst($str);

Here's a list of the functions related to ucfirst() function:

  • lcfirst() – Converts the first character of a string to lowercase.
  • ucwords() – Converts the first character of each word in a string to uppercase.
  • strtoupper() – Converts a string to uppercase.
  • strtolower() – Converts a string to lowercase.


The ucfirst() function accepts the following parameters.

Parameter Description
string Required. Specifies the string to work on.
Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties