php中强制字母转换大小写的方法有哪些-php教程

资源魔 31 0

strtoupper() 函数把字符串转换为年夜写。

strtolower() 函数把字符串转换为小写。

每一个单词的首字母转换为年夜写:ucwords()

<?php
$foo = 'hello world!';
$foo = ucwords($foo);             // Hello World!

$bar = 'HELLO WORLD!';
$bar = ucwords($bar);             // HELLO WORLD!
$bar = ucwords(strtolower($bar)); // Hello World!
?>

正在线学习视频保举:php视频教程

第一个单词首字母变年夜写:ucfirst()

<?php
$foo = 'hello world!';
$foo = ucfirst($foo);             // Hello world!
$bar = 'HELLO WORLD!';
$bar = ucfirst($bar);             // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>

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

<?php
$foo = 'HelloWorld';
$foo = lcfirst($foo);             // helloWorld
$bar = 'HELLO WORLD!';
$bar = lcfirst($bar);             // hELLO WORLD!
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
?>

相干文章教程保举:php教程

以上就是php中强迫字母转换巨细写的办法有哪些的具体内容,更多请存眷资源魔其它相干文章!

标签: php 方法 php开发教程 php开发资料 php开发自学 字母 大小写

抱歉,评论功能暂时关闭!