PHPstrtolower函数用法及示例:将字符串转换为小写
发布时间:2023-06-30 16:10:02
PHP的strtolower函数是用来将字符串转换为小写的。它的基本用法是通过传入一个字符串作为参数,然后返回一个将字符串中所有大写字符转换为小写后的新字符串。
下面是strtolower函数的基本语法:
strtolower(string $string): string
参数说明:
- $string:要转换为小写的字符串。
返回值:
- 返回一个转换为小写的新字符串。
下面是strtolower函数的示例:
$str = "HELLO WORLD"; $result = strtolower($str); echo $result;
输出:
hello world
在上面的示例中,我们将字符串"HELLO WORLD"传递给strtolower函数,并将返回值赋给$result变量。然后我们将$result变量的值输出结果为"hello world",即将字符串中的所有大写字母转换为小写字母。
