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

Guanhui
Release: 2023-03-01 16:20:02
Original
2693 people have browsed it

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

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"));
}

?>
Copy after login
<?php

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

?>
Copy after login



##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!

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!