分享php中几个字符函数小结
程序员文章站
2024-04-04 19:40:29
...
下面小结PHP中的几个字符函数, 小结一下:
1)ucfirst
将首字母变大写,比如
$string = "this is my web development blog";
echo ucfirst($string);
// Output: This is my web development blog
2) lcfirst,将首字母变小写
$string = "This is my Web Development Blog";
echo lcfirst($string);
// Output: this is my Web Development Blog
3)strtoupper,将整个字符串变大写
$string = "this is my web development blog";
echo strtoupper($string);
// Output: THIS IS MY WEB DEVELOPMENT BLOG
4)strtoplower,将整个字符串变小写
$string = "tHiS is mY WeB DevElOpMenT bLoG";
echo strtolower($string);
// Output: this is my web development blog
5)ucwords(),可以将句子中每个单词的第一个字母变大写,比如
$string = "this is my web development blog";
echo ucwords($string);
// Output: This Is My Web Development Blog
1)ucfirst
将首字母变大写,比如
$string = "this is my web development blog";
echo ucfirst($string);
// Output: This is my web development blog
2) lcfirst,将首字母变小写
$string = "This is my Web Development Blog";
echo lcfirst($string);
// Output: this is my Web Development Blog
3)strtoupper,将整个字符串变大写
$string = "this is my web development blog";
echo strtoupper($string);
// Output: THIS IS MY WEB DEVELOPMENT BLOG
4)strtoplower,将整个字符串变小写
$string = "tHiS is mY WeB DevElOpMenT bLoG";
echo strtolower($string);
// Output: this is my web development blog
5)ucwords(),可以将句子中每个单词的第一个字母变大写,比如
$string = "this is my web development blog";
echo ucwords($string);
// Output: This Is My Web Development Blog
推荐阅读
-
分享php中几个字符函数小结
-
PHP中字符安全过滤函数使用小结,php字符函数小结_PHP教程
-
php中数字、字符与对象判断函数用法实例,php实例
-
php中str_replace()字符替换函数的用法介绍
-
php strstr查找字符串中是否包含某些字符的查找函数_PHP教程
-
PHP中explode函数和split函数的区别小结
-
php中解析带中文字符的url函数分享
-
PHP中 htmlspecialchars 函数传入中文变量值后返回空字符串
-
php ucwords() 函数将字符串中每个单词的首字符转换为大写,ucwords大写_PHP教程
-
PHP中iconv函数转码时截断字符问题的解决方法,iconv截断_PHP教程