Home  >  Article  >  Backend Development  >  Which function is used to convert characters to uppercase in PHP?

Which function is used to convert characters to uppercase in PHP?

Guanhui
GuanhuiOriginal
2020-06-20 09:49:062692browse

Which function is used to convert characters to uppercase in PHP?

#Which function is used in PHP to convert characters to uppercase?

The function that converts characters to uppercase in PHP is "strtoupper()". The function of this function is to convert a string to uppercase. The syntax is "strtoupper(string $string)" and returns The value is the converted uppercase string.

Recommended video tutorial: "PHP Tutorial"

Sample code

<?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
?>

Usage example

<?php

define("LATIN1_UC_CHARS", "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝ");
define("LATIN1_LC_CHARS", "àáâãäåæçèéêëìíîïðñòóôõöøùúûüý");

function uc_latin1 ($str) {
    $str = strtoupper(strtr($str, LATIN1_LC_CHARS, LATIN1_UC_CHARS));
    return strtr($str, array("ß" => "SS"));
}

?>
<?php

function strtoupper_utf8($string){
    $string=utf8_decode($string);
    $string=strtoupper($string);
    $string=utf8_encode($string);
    return $string;
}

?>



##Related tutorials:《

PHP

The above is the detailed content of Which function is used to convert characters 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