PHP Tutorial PHP Advanced PHP Resources
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

PHP - String ucfirst() Function



The PHP String ucfirst() function returns 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 example below, ucfirst() function returns 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

5