Convert the first character to upper case in php


Capitalize first letter of the string of a word or sentence by using ucfirst() function.
Capitalize first letter of every word  in a sentence by using ucwords() function.

<?php

$string = "convert the first character to uppercase in PHP.";

$title = ucwords($string);
echo $title."\n";

$sentence = ucfirst($string);
echo $sentence;

?>

Output:

Convert The First Character To Uppercase In PHP.
Convert the first character to uppercase in PHP.


Comments

Popular posts from this blog

CakeAdminLTE is based on AdminLTE Theme for CakePHP 2.4+

The Rise of Tauri and Lightweight Desktop Apps

Hostinger | Free Web Hosting with PHP and MySQL, Website Builder, No Ads