<?php
function getParams() {
yield 'param1' => 'apple';
yield 'param2' => 'banana';
}
function foo(...$params) {
var_dump($params);
// I want this to be: [
// 'param1' => 'apple',
// 'param2' => 'banana'
// ]
}
foo(getParams());
- Output for 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.6 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
- array(1) {
[0]=>
object(Generator)#1 (0) {
}
}
- Output for 5.5.0 - 5.5.35
- Parse error: syntax error, unexpected '.', expecting '&' or variable (T_VARIABLE) in /in/VO3l8 on line 8
Process exited with code 255.
preferences:
130.37 ms | 401 KiB | 244 Q