generator_send.phpt 369 B

12345678910111213141516171819202122
  1. --TEST--
  2. Values can be sent back to the generator
  3. --FILE--
  4. <?php
  5. function gen() {
  6. var_dump(yield "yield foo");
  7. var_dump(yield "yield bar");
  8. }
  9. $gen = gen();
  10. var_dump($gen->current());
  11. $gen->send("send bar");
  12. var_dump($gen->current());
  13. $gen->send("send foo");
  14. ?>
  15. --EXPECT--
  16. string(9) "yield foo"
  17. string(8) "send bar"
  18. string(9) "yield bar"
  19. string(8) "send foo"