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/*from  w w  w  . j  av  a2  s . c  o m*/
$string = "java2s.com"; 
$a = ucfirst($string); 
print($a);
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions