The use and case of uppercase and lowercase conversion functions in PHP

Source: Internet
Author: User
Tags string back
The Strtoupper () function converts the string to uppercase and the Strtolower function: The function converts all characters of the passed-in string argument to lowercase and returns the string in a small form. Below through this article to share the PHP case conversion function (Strtolower, strtoupper) usage, need to refer to the friend

1, convert the string to lowercase

Strtolower function: This function converts all characters passed in the string argument to lowercase and puts the string back in a small form.

Example:

<?php  $str = "I want to FLY";  $str = Strtolower ($STR);  echo $str;//by www.jb51.net?>

Output:

I want to fly

2, turn the character into uppercase

Strtoupper function: This function, in contrast to the Strtolower function, converts the character of the passed character argument all to uppercase and returns the string in uppercase.

Use the same as Strtolower ().

Two useful functions are described below.

3, converts the first character of the string to uppercase

Ucfirst function: The function is to change the first character of a string to uppercase, which returns a string with the first character capitalized.

Usage is similar to the Strtolower () function.

4, converts the first character of each word in a string to uppercase

Ucwords: This function capitalizes the first character of each word in the passed-in string. such as "Hello World", after the function is processed, will return "Hello Word."

Usage is similar to Strtolower ().

Focus on the most commonly used functions

When writing a PHP program, it is often necessary to convert some strings into uppercase and lowercase, and here are a few of the most commonly used functions

Strtolower ()//convert string to lowercase

Strtoupper ()//convert string to uppercase

Ucfirst ()//converts the first character of a string to uppercase

Ucwords ()//converts the first letter of each word in a string to uppercase

Related recommendations:

PHP Case Sensitive issues

Introduction to PHP Case conversion functions (Strtolower, Strtoupper) usage

PHP Case problems: function names and class names are not distinguished, variable names are differentiated _php tutorials

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.