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

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

WBOY
WBOYOriginal
2016-07-13 10:02:44825browse

php method to convert the first letter of a string to uppercase, string capitalization

This article describes the example of php to convert the first letter of a string to uppercase. 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

<&#63;php
$string = "php string functions are easy to use.";
$sentence = ucfirst($string);
$title = ucwords($string);
print("$sentence\n");
print("$title\n");
print("\n");
&#63;>

The output results are as follows:

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969506.htmlTechArticlephp method to convert the first letter of a string into uppercase, string capitalization This article tells the example of how to realize the first letter of a string in php How to convert letters to uppercase. Share it with everyone for your reference. Specifically...
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