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

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

$foo = 'hello world!';

$foo = ucwords($foo); // Hello World!

$bar = 'HELLO WORLD!';

$bar = ucwords($bar); // HELLO WORLD!

$bar = ucwords(strtolower($bar)); // Hello World!

?>

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

$foo = 'hello world!';

$foo = ucfirst($foo); // Hello world!

$bar = 'HELLO WORLD!';

$bar = ucfirst($bar); // HELLO WORLD!

$bar = ucfirst(strtolower($bar)); // Hello world!

?>

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

$foo = 'HelloWorld';

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

$bar = 'HELLO WORLD!';

$bar = lcfirst($bar); // hELLO WORLD!

$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!

?>

字母变大写:strtoupper()

字母变小写:strtolower()


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部