2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > PHP中将首字母大写的函数 PHP 中的大小写字母转换函数 首字母变大写

PHP中将首字母大写的函数 PHP 中的大小写字母转换函数 首字母变大写

时间:2020-02-08 14:27:13

相关推荐

PHP中将首字母大写的函数 PHP 中的大小写字母转换函数 首字母变大写

PHP 中的大小写字母转换函数 首字母变大写:ucwords()<?php

$foo='helloworld!';

$foo=ucwords($foo);//HelloWorld!

$bar='HELLOWORLD!';

$bar=ucwords($bar);//HELLOWORLD!

$bar=ucwords(strtolower($bar));//HelloWorld!

?>

第一个词首字母变大写:ucfirst()<?php

$foo='helloworld!';

$foo=ucfirst($foo);//Helloworld!

$bar='HELLOWORLD!';

$bar=ucfirst($bar);//HELLOWORLD!

$bar=ucfirst(strtolower($bar));//Helloworld!

?>

第一个词首字母小写lcfirst()<?php

$foo='HelloWorld';

$foo=lcfirst($foo);//helloWorld

$bar='HELLOWORLD!';

$bar=lcfirst($bar);//hELLOWORLD!

$bar=lcfirst(strtoupper($bar));//hELLOWORLD!

?>

字母变大写:strtoupper()

字母变小写:strtolower()

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。