How does php convert the first letter of a string into uppercase and lowercase letters?

Source: Internet
Author: User
I have explained how to convert string uppercase and lowercase letters. However, sometimes we do not need to convert string letters in uppercase or lowercase, however, you only need to convert the first letter of a string in upper or lower case. So today, we will show you how to convert the first letter of a string in upper or lower case. I have explained how to convert string uppercase and lowercase letters. However, sometimes we do not need to convert string letters in uppercase or lowercase, however, you only need to convert the first letter of a string in upper or lower case.

Therefore, this article will help you understand,How to convert the first letter of a string in upper or lower case.

Converts the first letter of a string in uppercase or lowercase as follows:

First, the first letter of each word is converted to uppercase.

Converts the first letter of each word in a string to uppercase. We use the ucwords () function. The syntax is as follows:

ucwords(string)

The string parameter is the string to be converted.

Example

 

Code running result:

Case 2: convert the first letter of a word to uppercase

Convert the first letter of a word to uppercase. We use the ucfirst () function. The syntax is as follows:

ucfirst(string)

The string parameter is the string to be converted.

Example

 

Code running result:

The ucfirst () function only converts the first letter of the first word in uppercase, and the subsequent words are not converted.

Case 3: The first letter of a word is converted to lowercase letters.

Convert the first letter of a word to lowercase. We use the lcfirst () function. The syntax is as follows:

lcfirst(string)

The string parameter is the string to be converted.

Example

 

Code running result:

The lcfirst () function converts the letters of the first word to lowercase, rather than the first letter of each word to lowercase.

Converts the first letter of a string in upper or lower case. how does php convert the string in upper or lower case? The usage is similar. if you are interested, you can check it out.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.