How to make first letter of a word capital?

15,134

Solution 1

You may want to use ucfirst().

For multibyte strings, please see this snippet.

Solution 2

ucfirst capitalizes the first letter in a string.

ucwords capitalizes every word in a string.

Solution 3

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

Hope this would help!

Solution 4

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

Solution 5

This is the code you need:

<?php

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

?>
Share:
15,134
Admin
Author by

Admin

Updated on June 23, 2022

Comments

  • Admin
    Admin almost 2 years

    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.

  • Admin
    Admin about 13 years
    Thanks fabrik! This worked in first place and I think I will not be a beginner for any longer! Thanks again!
  • Admin
    Admin about 13 years
    THanks Philip, this helped me a lot!
  • Bogdan Constantinescu
    Bogdan Constantinescu about 13 years
    Well, actually this answer it's not so good. Why use ucwords() when you only need ucfirst(). Fabrik's answer is right on.
  • Admin
    Admin about 13 years
    Ok. As you say Bogdan Constantinescu.