Home >Backend Development >PHP Tutorial >Introduction to the usage of PHP case conversion functions (strtolower, strtoupper)
This article introduces the usage of the case conversion functions strtolower and strtoupper in PHP, which are often encountered in character processing problems. Friends in need, please refer to it.
1, Convert string to 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 bbs.it-home.org ?> 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 parameter into uppercase and returns the string in uppercase. The 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 the string with the first character uppercase. The usage is similar to the strtolower() function. 4, convert the first character of each word in the string to uppercase ucwords: This function capitalizes the first character of each word in the passed string. For example, "hello world", after processing by this function, "Hello Word" will be returned. Usage is similar to strtolower(). |