PageRenderTime 28ms CodeModel.GetById 4ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/test/slow/yield/2164.php

http://github.com/facebook/hiphop-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
  1. <?php
  2. function f($x, $y) {
  3. yield $x;
  4. yield $$y;
  5. }
  6. foreach (f(10, 'x') as $x) {
  7. var_dump($x);
  8. }
  9. function g() {
  10. extract(func_get_args(), EXTR_PREFIX_ALL, 'foo');
  11. yield $foo_0;
  12. yield $foo_1;
  13. }
  14. foreach (g('hello', 'world') as $x) {
  15. var_dump($x);
  16. }
  17. function h($x, $y) {
  18. $z = 16;
  19. $arr = compact('x', 'y', 'z');
  20. yield $arr['z'];
  21. yield $arr['x'];
  22. yield $arr['y'];
  23. }
  24. foreach (h(32, 64) as $x) {
  25. var_dump($x);
  26. }
  27. function i($x, $y) {
  28. $arr = compact($x);
  29. yield $arr[$x];
  30. }
  31. foreach (i('y', 32) as $x) {
  32. var_dump($x);
  33. }