3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function foo() { yield 'a'; yield 'b'; yield 'c'; } $gen1 = foo(); $gen2 = clone $gen1; var_dump(current($gen1)); var_dump(current($gen2)); $gen3 = clone $gen2; var_dump(current($gen3));
Output for 7.0.0 - 7.2.6
Fatal error: Uncaught Error: Trying to clone an uncloneable object of class Generator in /in/h1kt1:10 Stack trace: #0 {main} thrown in /in/h1kt1 on line 10
Process exited with code 255.
Output for hhvm-3.15.4
Warning: Invalid operand type was used: expecting an array in /in/h1kt1 on line 11 bool(false) Warning: Invalid operand type was used: expecting an array in /in/h1kt1 on line 12 bool(false) Warning: Invalid operand type was used: expecting an array in /in/h1kt1 on line 14 bool(false)
Output for 5.6.0 - 5.6.30
Fatal error: Trying to clone an uncloneable object of class Generator in /in/h1kt1 on line 10
Process exited with code 255.