PHP ucfirst()Functions

PHP String 参考手册PHP String Reference Manual

Examples

Convert the first character of "hello" to uppercase:

<?php
echo ucfirst("hello world!");
?>

Run example »

Definition and Usage

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

Related functions:

  • lcfirst()- Convert the first character of a string to lowercase
  • ucwords() - Convert the first character of each word in a string to uppercase
  • strtoupper()- Convert a string to uppercase
  • strtolower()- Convert a string to lowercase

Syntax

ucfirst(string)

Parameter Description
string Required. Specifies the string to convert.

Technical Details

Return value: Returns the converted string.
PHP Version: 4+


PHP String 参考手册PHP String Reference Manual Other Extensions