Home  >  Article  >  Backend Development  >  Summary of several character functions in php

Summary of several character functions in php

巴扎黑
巴扎黑Original
2016-11-24 14:00:401063browse

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

Statement:
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
Previous article:php array (Array)Next article:php array (Array)