Blogger Information
Blog 13
fans 0
comment 0
visits 10047
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
细说参数函数剩余参数2019年09月28日20时
加勒比强强的博客
Original
610 people have browsed it

实例

<?php
//$c是剩余参数的意思所有剩余的值都存在这里
function a($a,$b,...$c)
{

//array_product是计算数组中的乘积。
return $a*$b*array_product($c);
 
    
}
//其中,0.001和第一个10赋给a和b,其他给c
echo a(0.001,10,10,10,10,10);

echo'<br>';
//其中,0.01和第一个10赋给a和b,其他给c
echo a(0.01,10,10,10,10,10);
?>

运行实例 »

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


以上是剩余参数,适合数据量比较大的时候传入使用


Correction status:qualified

Teacher's comments:使用剩余 参数, 要注意一下php版本, 必须 7.0+
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
Author's latest blog post