<?php
$name = 'stefen';
$tel = '10795856';
$motto = 'If you shed tears when you miss the sun,then you would miss the stars';
function totalLen(...$string){
//=print_r($string);
foreach ($string as $content) {
echo strlen($content).',';
}
}
$arrNum = totalLen($name,$tel,$motto);
//totalLen($name,$tel,$motto)会得到6,8,69,但是貌似不能赋值给$arrNum
echo array_sum(array($arrNum));
我想实现的功能是,无论有多少变量传入函数,都能自动计算出所有字符的长度的和,但是现在没办法把得到的结果赋值给变量,求指教
1 回答
- 1 回答
- 0 关注
- 700 浏览
添加回答
举报
0/150
提交
取消