How To Convert the First Character to Upper Case

Q

How To Convert the First Character to Upper Case? - PHP Script Tips - PHP Built-in Functions for Strings

✍: FYIcenter.com

A

If you are processing an article, you may want to capitalize the first character of a sentence by using the ucfirst() function. You may also want to capitalize the first character of every words for the article title by using the ucwords() function. Here is a PHP script on how to use ucfirst() and ucwords():

<?php
$string = "php string functions are easy to use.";
$sentence = ucfirst($string);
$title = ucwords($string);
print("$sentence\n");
print("$title\n");
print("\n");
?>

This script will print:

Php string functions are easy to use.
Php String Functions Are Easy To Use.

2007-04-21, 4906👍, 0💬