Conversion method: 1. Use the strtoupper() function to convert all letters of the words in the string to uppercase, the syntax is "strtoupper(string)"; 2. Use the ucwords() function to convert the characters to uppercase The first letter of each word in the string is converted to uppercase, using the syntax "ucwords(string)".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php will string Convert Chinese words into uppercase letters
1. Use strtoupper() function
strtoupper() function can convert the letters in the string into Uppercase, the syntax format is as follows:
strtoupper($string)
Among them, $string is a string type parameter. This function can convert the letters in the parameter $string to uppercase and return the converted string. .
Example:
<?php $str = "Hello World"; echo strtoupper($str);; ?>
2. Use the ucwords() function
ucwords() function to convert the string The first character of each word in the parameter $string is converted to uppercase. The syntax format is as follows:
ucwords($string)
Among them, $string is a parameter of string type. This function can convert the first character of each word in the parameter $string to Uppercase and return the converted string.
Example:
<?php $str = "Hello World"; echo ucwords($str);; ?>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to convert words to uppercase letters in php. For more information, please follow other related articles on the PHP Chinese website!