How to make first letter of a word capital?

15.7k Views Asked by At

I have a word default and I want a php function to make only first letter capital. Can we do that. Please help me out as I am very new to php coding.

5

There are 5 best solutions below

1
On BEST ANSWER

You may want to use ucfirst().

For multibyte strings, please see this snippet.

0
On

This is the code you need:

<?php

$string = 'stackoverflow';
$string = ucfirst($string);
echo $string;

?>
0
On

ucfirst capitalizes the first letter in a string.

ucwords capitalizes every word in a string.

2
On

Hello Geeta you can simply use ucwords() php function to make every first letter of your word Upper Cased!

Hope this would help!

0
On

I think that https://www.php.net/manual/en/function.ucwords.php is the best function here :)