PHP ucfirst() Function

PHP ucfirst() Function converts only the first character of a string into uppercase. The ucfirst() Function is php in-built function.

Syntax :

ucfirst(string);

Parameters ,

string : Required. It is required to make only the first characters of string to uppercase.

It returns the uppercased first characters of whole string.

Similar function of ucfirst() :

    ucwords(): It makes the first character of each word to uppercase in string..
    strtolower() : It converts a whole string into lowercase.
    lcfirst() : It converts only the first character of a string into lowercase.
    strtoupper() : It converts a whole string into uppercase.

Let's see below example to understand php ucfirst() Function in details.

Example :

<?php
$str= 'LEARN PHP UCFIRST FUNCTION TUTORIAL AT ARYATECHNO!';
$result1= ucfirst(strtolower($str));
echo "<br> ucfirst function for uppercase string : ".$result1;

$str= 'learn php ucfirst function tutorial at aryatechno!';
$result1= ucfirst($str);
echo "<br> ucfirst function for lowercase string : ".$result1;
?>

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

40087