Summary of several character functions in php

巴扎黑
Release: 2016-11-24 14:00:40
Original
1085 people have browsed it

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

Related labels:
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