
php将字符串首字母转换大写字母的方法:首先新建一个php示例文件;然后设置字符串;最后通过ucfirst函数将一个字符串中的第一个字母转换成大写即可。

php将字符串首字母转换大写字母的方法:
php中可以通过ucfirst函数将一个字符串中的第一个字母转换成大写,而ucwords函数可以将一个字符串中每个单词的首字母转换成大写
<?php
$string = "php string functions are easy to use.";
$sentence = ucfirst($string);
$title = ucwords($string);
print("$sentence
");
print("$title
");
print("
");
?>输出结果如下:
Php string functions are easy to use. Php String Functions Are Easy To Use
相关学习推荐:php编程(视频)
