PHP ucfirst() Function

❮ PHP String Reference

Example

Convert the first character of "hello" to uppercase:

<?php
echo ucfirst("hello world!");
?>
Try it Yourself »

Definition and Usage

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

Related functions:

  • 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

Syntax

ucfirst(string)

Parameter Values

Parameter Description
string Required. Specifies the string to convert

Technical Details

Return Value: Returns the converted string
PHP Version: 4+

❮ PHP String Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.