Php string conversion case-insensitive instance _ PHP Tutorial

Source: Internet
Author: User
Php string conversion case. In php, if we want to convert characters into uppercase and lowercase letters, use strtolower or strtoupper directly, however, to convert the first letter to the upper and lower case, we need to use the ucwords function to change the first letter to the upper and lower case in php. if we want to convert the character to the upper and lower case, use strtolower or strtoupper directly, however, to convert the first letter to the upper case, we need to use ucwords-related functions.

Uppercase letters: ucwords ()

The code is as follows:

$ Foo = 'Hello world! ';
$ Foo = ucwords ($ foo); // Hello World!

$ Bar = 'Hello WORLD! ';
$ Bar = ucwords ($ bar); // hello world!
$ Bar = ucwords (strtolower ($ bar); // Hello World!
?>

The first letter is capitalized: ucfirst ()

The code is as follows:

$ Foo = 'Hello world! ';
$ Foo = ucfirst ($ foo); // Hello world!

$ Bar = 'Hello WORLD! ';
$ Bar = ucfirst ($ bar); // hello world!
$ Bar = ucfirst (strtolower ($ bar); // Hello world!
?>

Lowercase lcfirst ()

The code is as follows:

$ Foo = 'helloworld ';
$ Foo = lcfirst ($ foo); // helloWorld

$ Bar = 'Hello WORLD! ';

The first letter of Begin is changed...

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.