php将字符串中单词转换成大写字母
php将字符串中单词转换成大写字母
1、使用strtoupper()函数
strtoupper() 函数可以将字符串中的字母转化为大写,语法格式如下:
strtoupper($string)
其中,$string 为一个字符串类型的参数,该函数可以将参数 $string 中的字母转化为大写,并将转化后的字符串返回。
示例:
<?php
$str = "Hello World";
echo strtoupper($str);;
?>
运行结果:

2、使用ucwords()函数
ucwords() 函数把字符串中每个单词的首字符转换为大写,语法格式如下:
ucwords($string)
其中,$string 为一个字符串类型的参数,该函数可以将参数 $string 中每个单词的首字符转换为大写,并将转化后的字符串返回。
示例:
<?php
$str = "Hello World";
echo ucwords($str);;
?>
运行结果:

我们的基础服务有:企业网站设计与制作、移动端开发、电商网站建设设计、网站SEO优化、服务器租用与托管等。我们追求一流的用户体验,为客户创造价值从而实现自身价值!
相关推荐
-
PHP8种变量类型的详细讲解2025-02-22 00:32:24
-
php+apache 和 php+nginx的区别2025-02-22 00:21:27
-
PHP:与workerman结合实现定时任务2025-02-22 00:15:57
-
Nginx的Rewrite规则与实例2025-02-22 00:15:39
-
MySql中身份证字段的简单脱敏介绍2025-02-22 00:15:36