This article mainly introduces several PHP uppercase/lowercase conversion functions, which can be used to convert letters into uppercase/lowercase letters or convert all letters into uppercase/lowercase letters. For more information, see
This article mainly introduces several PHP uppercase/lowercase conversion functions, which can be used to convert letters into uppercase/lowercase letters or convert all letters into uppercase/lowercase letters. For more information, see
The initial letter of each word is converted to uppercase: 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!
?>
The first letter of a word becomes smaller: lcfirst ()
The Code is as follows:
$ Foo = 'helloworld ';
$ Foo = lcfirst ($ foo); // helloWorld
$ Bar = 'Hello WORLD! ';
$ Bar = lcfirst ($ bar); // hELLO WORLD!
$ Bar = lcfirst (strtoupper ($ bar); // hELLO WORLD!
?>
Uppercase for all letters: strtoupper ()
Write down all letters: strtolower ()
,