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.


The syntax of the ucfirst() function:



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

$str = "this is MY computer!";

echo (ucfirst($str));


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 All rights reserved.