时间:2021-07-01 10:21:17 帮助过:2人阅读
<?php
//函数定义:
function countWords($str){
echo (mb_strlen($str, 'utf8') + strlen($str))/2;
}
//使用方法:
$strdemo1='欢迎访问脚本之家';
$strdemo2='http://www.gxlcms.com';
$strdemo3='欢迎访问脚本之家http://www.gxlcms.com';
countWords($strdemo1);
echo "<br/>";
countWords($strdemo2);
echo "<br/>";
countWords($strdemo3);
?>运行结果:
16 19 35
相关推荐:
javascript回调函数定义和使用场合实例详解、
javascript函数定义、调用模式及this的初始化实例详解
php自定义函数定义及语法实例详解
以上就是php统计字数函数定义和使用方法的详细内容,更多请关注Gxl网其它相关文章!