Blogger Information
Blog 20
fans 1
comment 2
visits 16779
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
写一个函数,计算不定参数的乘积, 要求使用到剩余参数来实现
月迎下弦的博客
Original
821 people have browsed it

实例

<?php 
$a=1;
function  product (...$z)
{

  $argArr = func_get_args($z);
  print_r($argArr);
   echo '<hr>';
//    计算数组中所有值的乘积
//1
        
        // foreach ($argArr as  $arg) {
        //         $GLOBALS['a']*=$arg;
        //    }
        //    return $GLOBALS['a'];
       
//2  计算乘积函数
return array_product($z) ;

}

echo    product (1,4,2,2,3,4);

运行实例 »

点击 "运行实例" 按钮查看在线实例

总结

1.jpg2.jpg

3.jpg

4.jpg

Correction status:qualified

Teacher's comments:完成的相当完美, 有图有真相
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments