代码如下:

<?php

header("Content-type:text/html;charset=utf-8");

/*

* 语法结构:ucwords(string)

* 说明:把字符串中每个单词的首字符转换为大写

* 参数:string规定要转换的字符串

* 注意:首字符必须是字母才转换为大写字母

*/

$str = ucwords("hello world!");

var_dump($str);

截图如下:

运行结果如下: