Example 1 — Capitalize the First Letter
Turn the first letter of a sentence into a capital.
<?php
$text = "hello world";
echo ucfirst($text), PHP_EOL; How It Works
- Start with lowercase text. Every letter is small.
- Call ucfirst(). Only the first character is changed.
- Rest unchanged.
worldkeeps its lowercase. - Print. You see
Hello world.

