strtoupper() function converts the string to uppercase and strtolower function: This function converts all characters of the incoming string parameter to lowercase and puts the string back in small definite form. This article will share with you the usage of PHP case conversion functions (strtolower, strtoupper). Friends who need it can refer to
1 to convert strings into lowercase
strtolower function: This function converts all characters of the incoming string parameter to lowercase and puts them back into the string in decimal form.
Example:
<?php $str = "I want To FLY"; $str = strtolower($str); echo $str; //by www.jb51.net ?>
Output:
i want to fly
2, Convert characters to uppercase
strtoupper function: The function of this function is opposite to the strtolower function. It converts all the characters of the incoming character parameters into uppercase and returns this in uppercase. string.
Usage is the same as strtolower().
Here are two more useful functions.
3, Convert the first character of the string to uppercase
ucfirst function: The function of this function is to change the first character of the string to uppercase. This function Returns a string whose first character is uppercase.
Usage is similar to strtolower() function.
4, Convert the first character of each word in the string to uppercase
ucwords: This function converts the first character of each word in the incoming string into uppercase into uppercase. For example, "hello world", after processing by this function, "Hello Word" will be returned.
Usage is similar to strtolower().
Let’s focus on the most commonly used functions
When writing PHP programs, you often need to capitalize some strings Conversion, here are some of the most commonly used functions
strtolower() //Convert the string to lowercase form
strtoupper() //Convert the string to uppercase form
ucfirst() //Convert the first character of the string to uppercase
ucwords() //Convert the first letter of each word in the string For uppercase form
Related recommendations:
php case conversion function ( strtolower, strtoupper) usage introduction
The above is the detailed content of Usage and cases of case conversion function in php. For more information, please follow other related articles on the PHP Chinese website!