Share a summary of several character functions in PHP_PHP Tutorial

WBOY
Release: 2016-07-13 17:48:36
Original
799 people have browsed it

Below is a summary of several character functions in PHP. To summarize:

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478433.htmlTechArticleThe following is a summary of several character functions in PHP. To summarize: 1) ucfirst capitalizes the first letter, such as $ string = this is my web development blog; echo ucfirst($string); // Output: Th...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!