PHP将字符转为大写的函数是哪个?

来自:互联网
时间:2020-06-20
阅读:

PHP将字符转为大写的函数是哪个?lcJ免费资源网

在PHP中将字符转为大写的函数是“strtoupper()”,该函数的作用是将字符串转化为大写,语法为“strtoupper(string $string)”,返回值为转换后的大写字符串。lcJ免费资源网

示例代码lcJ免费资源网

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

使用示例lcJ免费资源网

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

?>
返回顶部
顶部