Home >Backend Development >PHP Tutorial >Summary of several character functions in php
Below is a summary of several character functions in PHP:
1) ucfirst
Change the first letter to uppercase, such as
$string = "this is my web development blog";
echo ucfirst($string);
// Output: This is my web development blog
2) lcfirst, change the first letter to lowercase
$string = "This is my Web Development Blog";
echo lcfirst($string);
// Output: this is my Web Development Blog
3) strtoupper, capitalize the entire string
$string = "this is my web development blog";
echo strtoupper($string);
// Output: THIS IS MY WEB DEVELOPMENT BLOG
4) strtolower, change the entire string to lowercase
$string = "tHiS is mY WeB DevElOpMenT bLoG";
echo strtolower($string);
// Output: this is my web development blog
5) ucwords(), you can capitalize the first letter of each word in the sentence, such as
$string = "this is my web development blog";
echo ucwords($string);
// Output: This Is My Web Development Blog