3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = new ArrayObject(array(1, 2)); $it = new ArrayIterator($array); while ($it->valid()) { echo $it->current(); $prev = clone $it; $it->next(); } $array[] = 3; $it = $previous; $previous->next(); echo $it->valid() ? $it->current : "not valid";
Output for 7.0.5 - 7.1.0
12 Notice: Undefined variable: previous in /in/b9T3N on line 16 Notice: Undefined variable: previous in /in/b9T3N on line 17 Fatal error: Uncaught Error: Call to a member function next() on null in /in/b9T3N:17 Stack trace: #0 {main} thrown in /in/b9T3N on line 17
Process exited with code 255.
Output for 7.0.0 - 7.0.4
12 Notice: Undefined variable: previous in /in/b9T3N on line 16 Notice: Undefined variable: previous in /in/b9T3N on line 17 Fatal error: Uncaught Error: Call to a member function next() on unknown in /in/b9T3N:17 Stack trace: #0 {main} thrown in /in/b9T3N on line 17
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
12 Notice: Undefined variable: previous in /in/b9T3N on line 16 Notice: Undefined variable: previous in /in/b9T3N on line 17 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function next() on a non-object (null)' in /in/b9T3N:17 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.28
12 Notice: Undefined variable: previous in /in/b9T3N on line 16 Notice: Undefined variable: previous in /in/b9T3N on line 17 Fatal error: Call to a member function next() on null in /in/b9T3N on line 17
Process exited with code 255.
Output for 5.0.4 - 5.5.38
12 Notice: Undefined variable: previous in /in/b9T3N on line 16 Notice: Undefined variable: previous in /in/b9T3N on line 17 Fatal error: Call to a member function next() on a non-object in /in/b9T3N on line 17
Process exited with code 255.
Output for 5.0.0 - 5.0.3
12 Notice: Undefined variable: previous in /in/b9T3N on line 16 Notice: Undefined variable: previous in /in/b9T3N on line 17 Fatal error: Call to a member function next() on a non-object in /in/b9T3N on line 17
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_VARIABLE in /in/b9T3N on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_VARIABLE in /in/b9T3N on line 10
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/b9T3N on line 10
Process exited with code 255.