PHP ucfirst() function with example

By IncludeHelp Last updated : December 27, 2023

PHP ucfirst() function

The ucfirst() function is a string function, it is used to convert first character to uppercase. It accepts string and returns string with first uppercase character.

Syntax

The syntax of the ucfirst() function:

ucfirst(string);

Parameters

The parameters of the ucfirst() function:

  • string: An input parameter.

Sample Input/Output

Input: "this is MY computer!"
Output: "This is MY computer!"

Example of PHP ucfirst() Function

<?PHP
$str = "this is MY computer!";

echo (ucfirst($str));
?>

Output

The output of the above example is:

This is MY computer!

To understand the above example, you should have the basic knowledge of the following PHP topics:

All PHP Programs

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.