Slide 147
Slide 147 text
Proprietary and Confidential
Variadic Functions
function fn($reqParam, $optParam = null, ...$params) {
var_dump($reqParam, $optParam, $params);
}
fn(1); // 1, null, []
fn(1, 2); // 1, 2, []
fn(1, 2, 3); // 1, 2, [3]
fn(1, 2, 3, 4); // 1, 2, [3, 4]
fn(1, 2, 3, 4, 5); // 1, 2, [3, 4, 5]
5.6