In the previous article, we learned about how to change the case of the first character of a string. If you need it, please read "The first character of a string is a disaster!" 》. This time we will introduce to you how to change the case of string characters. You can refer to it if you need it.
We left two functions unmentioned before. I don’t know if you are still impressed. If it doesn’t affect you, read my last article again. This time we will introduce these two functions.
First of all, we introduce the function that converts all characters to uppercase.
Let’s look at a small example.
<?php echo strtoupper("Hello WORLD!"); ?>
The result is
We will know the meaning of this function by looking at the result. The strtoupper function can convert all characters in the string Convert to uppercase, so that when we view the output results, all characters will be uppercase.
After we know this function, let's take a look at its usage, give yourself a deeper influence, and remember this function.
strtoupper(要转换的字符串)
Now that we’ve finished talking about the function that converts all characters to uppercase, let’s talk about the function that converts all characters to lowercase.
Let’s take a look at a little chestnut.
<?php echo strtolower("Hello WORLD."); ?>
This result is
The function of this function is opposite to the strtoupper function. It converts all the characters of the incoming character parameters into lowercase and ends with Returns this string in lowercase form. The usage is the same as strtoupper().
Although it's the same, let's take a look at the usage of this function to deepen our impression.
strtoupper(要转换的字符串)
Finally, let’s recommend a few commonly used functions.
When writing PHP programs, you often need to convert uppercase and lowercase strings, which are very useful. (ps: including those introduced before)
strtolower()
//Convert the string to lowercase form
strtoupper()
//Convert the string to uppercase form
lcfirst()
//Convert the first character of the string to lowercase form
ucfirst()
//Convert the first character of the string to uppercase
ucwords()
//Convert the first letter of each word in the string That’s it for the capitalized form
. If you want to know anything else, you can click this. → →php video tutorial
The above is the detailed content of Continue to destroy all characters in the string. For more information, please follow other related articles on the PHP Chinese website!