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...