Facebook Page Twitter Page LinkedIn Page
× PHP Tutorial PHP Advanced PHP Resources


The PHP String ucfirst() function is used to return the string with first character of the specified string in the uppercase. Any symbol, space, special character or number in the string is ignored while applying this function. Only Alphabets are converted.

Syntax

ucfirst(string)

Parameters

string Required. Specify the string to convert

Return Value

Returns the string with first character of the specified string in uppercase.

Example:

In the below example, ucfirst() function is used to return a string with first character of the string MyString in the uppercase.

<?php
$MyString = "hello world!";
$NewString = ucfirst($MyString);

echo $NewString."\n";
?>

The output of the above code will be:

Hello world!

❮ PHP String functions