We know that in PHP to implement the case conversion can use the Strtolower function, then today we will give you a very brief introduction of how to use PHP to achieve this effect.
1, convert the string to lowercase
Strtolower function: This function converts all characters passed in the string argument to lowercase and puts the string back in a small form.
Example:
<?php $str = "I want to FLY"; $str = Strtolower ($STR); Echo $str;? >
Output:
I want to fly
2, turn the character into uppercase
Strtoupper function: This function, in contrast to the Strtolower function, converts the character of the passed character argument all to uppercase and returns the string in uppercase.
Use the same as Strtolower ().
Two useful functions are described below.
3, converts the first character of the string to uppercase
Ucfirst function: The function is to change the first character of a string to uppercase, which returns a string with the first character capitalized.
Usage is similar to the Strtolower () function.
4, converts the first character of each word in a string to uppercase
Ucwords: This function capitalizes the first character of each word in the passed-in string. such as "Hello World", after the function is processed, will return "Hello Word."
Usage is similar to Strtolower ().
Focus on the most commonly used functions
When writing a PHP program, it is often necessary to convert some strings into uppercase and lowercase, and here are a few of the most commonly used functions
Strtolower ()//converts a string to lowercase strtoupper ()//Converts a string to uppercase Ucfirst ()//converts the first character of a string to uppercase ucwords ()//converts the first letter of each word in a string to uppercase
Believe that you have seen these cases you have mastered the method, more wonderful please pay attention to the PHP Chinese network other related articles!
Related reading:
An example of Ajax asynchronous request technology
What is the common syntax for Ajax?
PHP commodity seconds to kill timing implementation (to solve large traffic scenarios)