Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 这些是什么。。。在这个例子中是什么意思?_Php - Fatal编程技术网

Php 这些是什么。。。在这个例子中是什么意思?

Php 这些是什么。。。在这个例子中是什么意思?,php,Php,我正在学习PHP,在下面的示例中,我不理解函数定义中带有$ints参数的.. <?php // Coercive mode function sumOfInts(int ...$ints) { return array_sum($ints); } var_dump(sumOfInts(2, '3', 4.1)); 这意味着当调用该函数时,可以传递X个整数,该函数将处理它们,而不管它们有多少。如果调用sumOfInts(3,4,6,2,9)或sumOfInts(3,2,9),则无

我正在学习PHP,在下面的示例中,我不理解函数定义中带有
$ints
参数的
..

<?php
// Coercive mode
function sumOfInts(int ...$ints)
{
    return array_sum($ints);
}

var_dump(sumOfInts(2, '3', 4.1));

这意味着当调用该函数时,可以传递X个整数,该函数将处理它们,而不管它们有多少。如果调用
sumOfInts(3,4,6,2,9)
sumOfInts(3,2,9)
,则无论传递多少个参数,函数都会工作

Search,Search,然后再Search。。。。然后问一个问题这允许您拥有可变数量的参数$ints是一个数组。