Convert the first character to upper case in php


Capitalize first letter of the string of a word or sentence by using ucfirst() function.
Capitalize first letter of every word  in a sentence by using ucwords() function.

<?php

$string = "convert the first character to uppercase in PHP.";

$title = ucwords($string);
echo $title."\n";

$sentence = ucfirst($string);
echo $sentence;

?>

Output:

Convert The First Character To Uppercase In PHP.
Convert the first character to uppercase in PHP.


Comments