php中字符串大小写转换

ucfirst() 函数把字符串中的首字符转换为大写。

$str="hello world";

echo ucfirst($str);

运行结果为:

Hello world 

lcfirst() - 把字符串中的首字符转换为小写

$str="Hello world";

echo lcfirst($str);

运行结果为:

hello world

strtolower() - 把字符串转换为小写

$str="Hello world";

echo strtolower($str);

运行结果为:

hello world

strtoupper() - 把字符串转换为大写

$str="hello world";

echo strtoupper($str);

运行结果为:

HELLO WORD

ucwords() - 把字符串中每个单词的首字符转换为大写

$str="hello world";

echo strtoupper($str);

运行结果为:

Hello World

lcfirst() - 将字符串中的首字符转换为小写

$str="HELLO WORLD";

echo lcfirst($str)."<br>";

运行结果为:

hELLO WORLD

strtolower() - 将整个字符串转换为小写

$str="HELLO WORLD";

echo strtolower($str)."<br>";

运行结果为:

hello world

strtoupper() - 将整个字符串转换为大写

$str="hello WORLD";

echo strtoupper($str)."<br>";

运行结果为:

HELLO WORLD

ucwords() - 将字符串中每个单词的首字符转换为大写

$str="hello world";

echo ucwords($str)."<br>";

运行结果为:

Hello World


相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...