一、场景一
- 开发过程设置常量需要,平常小写输入,需要转换成大写
- 或者原本大写常量,有个参数需要对应小写,需要转换成小写
基础phpstorm开发快捷方法
- 选中要转换的文本,然后按下
Ctrl+Shift+U
组合键,可以将选中的文本转换为大写字母。如果要将其转换为小写字母,再按一次该组合键即可。
- 另外,在菜单栏中依次选择
"Edit"
=>"Change Case"
,也可以将选中的文本转换为大写或小写字母。
二、场景二
- 开发的时候有业务场景需要处理字符大小写(接口对接
or
文案展示规范等)
php代码处理转换
$str = "Hello World";
$lowerStr = strtolower($str);
echo $lowerStr; // 输出:hello world
$str = "Hello World";
$upperStr = strtoupper($str);
echo $upperStr; // 输出:HELLO WORLD
$str = "hello world";
$ucfirstStr = ucfirst($str);
echo $ucfirstStr; // 输出:Hello world
$str = "hello world";
$ucwordsStr = ucwords($str);
echo $ucwordsStr; // 输出:Hello World