Home » Php » php – How to make first letter of a word capital?

php – How to make first letter of a word capital?

Posted by: admin July 12, 2020 Leave a comment

Questions:

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.

How to&Answers:

You may want to use ucfirst().

For multibyte strings, please see this snippet.

Answer:

ucfirst capitalizes the first letter in a string.

ucwords capitalizes every word in a string.

Answer:

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

Hope this would help!

Answer:

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

Answer:

This is the code you need:

<?php

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

?>