PHP中的几个字符函数

  下面小结PHP中的几个字符函数,小结一下:

1)ucfirst

将首字母变大写,比如

$string="thisismywebdevelopmentblog";

echoucfirst($string);

//Output:Thisismywebdevelopmentblog

2)lcfirst,将首字母变小写

$string="ThisismyWebDevelopmentBlog";

echolcfirst($string);

//Output:thisismyWebDevelopmentBlog

3)strtoupper,将整个字符串变大写

$string="thisismywebdevelopmentblog";

echostrtoupper($string);

//Output:THISISMYWEBDEVELOPMENTBLOG

4)strtolower,将整个字符串变小写

$string="tHiSismYWeBDevElOpMenTbLoG";

echostrtolower($string);

//Output:thisismywebdevelopmentblog

5)ucwords(),可以将句子中每个单词的第一个字母变大写,比如

$string="thisismywebdevelopmentblog";

echoucwords($string);

// Output: This Is My Web Development Blog

相关推荐