PHP Tutorial - PHP ucfirst() Function






Definition

The ucfirst() function takes string and converts its first letter to an uppercase character.

Syntax

PHP ucfirst() Function has the following syntax.

string ucfirst ( string str )

Parameter

str is the value we want to convert.

Return

PHP ucfirst() function returns the string with first letter converted.

Example

Convert the first letter to uppercase


<?PHP
$string = "java2s.com"; 
$a = ucfirst($string); 
print($a);
?>

The code above generates the following result.