array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.strtoupper.php', 1 => 'strtoupper', ), 'up' => array ( 0 => 'ref.strings.php', 1 => '字符串 函数', ), 'prev' => array ( 0 => 'function.strtolower.php', 1 => 'strtolower', ), 'next' => array ( 0 => 'function.strtr.php', 1 => 'strtr', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/strings/functions/strtoupper.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
strtoupper — 将字符串转化为大写
将 string
中所有 ASCII 字母字符转换为大写并返回。
"a"
(0x61)到 "z"
(0x7a)范围内的字节会通过将每个字节值减 32 转为相应的大写字母。
这可用于转换用 UTF-8 编码的字符串中的 ASCII 字符,但会忽略多字节 UTF-8 字符。要转换多字节非 ASCII 字符,请使用 mb_strtoupper()。
string
输入字符串。
返回转换后的大写字符串。
版本 | 说明 |
---|---|
8.2.0 | 大小写转换不在依赖于使用 setlocale() 设置的区域。只会转换 ASCII 字符。 |
示例 #1 strtoupper() 示例
<?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
?>
注意: 此函数可安全用于二进制对象。