Home > Backend Development > PHP Tutorial > PHP method to convert the first letter of a string to uppercase_PHP tutorial

PHP method to convert the first letter of a string to uppercase_PHP tutorial

WBOY
Release: 2016-07-13 10:03:08
Original
908 people have browsed it

How to convert the first letter of a string to uppercase in php

This article mainly introduces the method of converting the first letter of a string to uppercase in php, involving ucfirst and ucwords in php For tips on using functions, friends who need it can refer to it

The example in this article describes how to convert the first letter of a string to uppercase in PHP. Share it with everyone for your reference. The specific analysis is as follows:

In PHP, you can use the ucfirst function to convert the first letter in a string to uppercase, and the ucwords function can convert the first letter of each word in a string to uppercase

?

1

2

3

4

5

6

7

8

$string = "php string functions are easy to use.";

$sentence = ucfirst($string);

$title = ucwords($string);

print("$sentencen");

print("$titlen");

print("n");

?>

1 2

3

4

5

6

1

2

Php string functions are easy to use.

Php String Functions Are Easy To Use

7 8

$string = "php string functions are easy to use.";

$sentence = ucfirst($string);$title = ucwords($string); print("$sentensen"); print("$titlen"); print("n"); ?>
The output results are as follows:
?
1 2 Php string functions are easy to use. Php String Functions Are Easy To Use
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/969349.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969349.htmlTechArticleHow to convert the first letter of a string to uppercase in php. This article mainly introduces how to convert the first letter of a string in php. The method of capitalizing, involves the use skills of ucfirst and ucwords functions in php...
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