Home  >  Article  >  Backend Development  >  How to convert all strings to uppercase in php

How to convert all strings to uppercase in php

藏色散人
藏色散人Original
2021-12-22 10:35:373081browse

php method to convert all strings to uppercase: 1. Create a PHP sample file; 2. Define the variables that need to be converted; 3. Convert the incoming character parameters through "strtoupper($str);" Convert all characters to uppercase and return the string in uppercase.

How to convert all strings to uppercase in php

The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.

How to convert all strings to uppercase in php?

Convert characters to uppercase:

strtoupper():

The function of this function is the opposite of the strtolower function. It converts all the characters of the incoming character parameters Convert to uppercase and return the string in uppercase. The usage is the same as strtolowe().

The code is as follows

$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtoupper($str);
echo $str; // 打印 MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
?>

Related introduction:

strtolower( ): This function converts all characters of the passed string parameter into lowercase and puts them back into the string in decimal form.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to convert all strings to uppercase in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn