/hphp/test/slow/yield/2164.php
PHP | 35 lines | 33 code | 2 blank | 0 comment | 0 complexity | f7f6e8b2fbe46a203a4984b0a2ada145 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
- <?php
- function f($x, $y) {
- yield $x;
- yield $$y;
- }
- foreach (f(10, 'x') as $x) {
- var_dump($x);
- }
- function g() {
- extract(func_get_args(), EXTR_PREFIX_ALL, 'foo');
- yield $foo_0;
- yield $foo_1;
- }
- foreach (g('hello', 'world') as $x) {
- var_dump($x);
- }
- function h($x, $y) {
- $z = 16;
- $arr = compact('x', 'y', 'z');
- yield $arr['z'];
- yield $arr['x'];
- yield $arr['y'];
- }
- foreach (h(32, 64) as $x) {
- var_dump($x);
- }
- function i($x, $y) {
- $arr = compact($x);
- yield $arr[$x];
- }
- foreach (i('y', 32) as $x) {
- var_dump($x);
- }