账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    函数的结果怎么赋值给变量啊
    64
    0
    <?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));
    

    我想实现的功能是,无论有多少变量传入函数,都能自动计算出所有字符的长度的和,但是现在没办法把得到的结果赋值给变量,求指教

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 帅领一群 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部