How to convert the first letter of a string to uppercase in PHP

The ucfirst() function is used to change the first character of a string to uppercase. Otherwise, We can use the strtolower() function in combination with the ucfirst() function, if you need to make only first letter of the string to uppercase and rest of the string to lowercase.

Syntax:

ucfirst(string)

string – This parameter is required. It converts the first character of a string to uppercase.

Example:

<?php
$str = 'php tutorials!';
echo ucfirst($str);             // Php tutorials!
echo "<br>";
$str1 = 'PHP Tutorials!';
echo ucfirst($str1);           // PHP Tutorials!
echo "<br>";          
echo ucfirst(strtolower($str1));  // Php tutorials!
?>

Chockalingam