php如何实现字符串大小写转换
php如何实现字符串大小写转换,下面编程教程网小编给大家简单介绍以下2个语法的运用!
1、利用strtoupper转成大写
<?php
header('content-type:text/html;charset=utf-8');
echo strtoupper("Hello WORLD!");
?>
2、利用mb_convert_case大小写转换
<?php
$str = "mary had a Little lamb and she loved it so";
$str = mb_convert_case($str, MB_CASE_UPPER, "UTF-8");
echo $str."<br>"; // 输出 MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
$str = mb_convert_case($str, MB_CASE_TITLE, "UTF-8");
echo $str; // 输出 Mary Had A Little Lamb And She Loved It So
?>
// MB_CASE_UPPER —— 转换为大写
// MB_CASE_LOWER —— 转换为小写
// MB_CASE_TITLE —— 单词首字母转换为大写
以上是编程学习网小编为您介绍的“php如何实现字符串大小写转换”的全面内容,想了解更多关于 php入门 内容,请继续关注编程基础学习网。