Home > Backend Development > PHP Problem > How to convert string to uppercase in PHP?

How to convert string to uppercase in PHP?

Guanhui
Release: 2023-03-01 13:22:02
Original
3477 people have browsed it

How to convert string to uppercase in PHP?

#PHP How to convert a string to uppercase?

In PHP, you can use the "strtoupper()" function to convert a string to uppercase.

Syntax and Description

strtoupper ( string $string ) : string
Copy after login

Converts all alphabetic characters in string to uppercase and back.

Note that "letter" is related to the current area. For example, in the default "C" locale, the character umlaut-a (ä) is not converted.


Code sample

<?php
$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
?>
Copy after login

Recommended tutorial: "PHP Tutorial"

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

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template