3v4l.org

run code in 300+ PHP versions simultaneously
<?php class test { private $a = 1; protected $b = 2; public $c = 3; private $d = 4; protected $e = 5; public $f = 6; } $obj = new test; echo "BROKEN:\n"; var_dump(reset($obj)); var_dump(current($obj)); var_dump(next($obj)); var_dump(prev($obj)); var_dump(end($obj)); echo "\nWORKING:\n"; foreach ($obj as $item) { var_dump($item); }
Output for 8.1rc1 - rc2
BROKEN: Deprecated: reset(): Calling reset() on an object is deprecated in /in/5e6Ok on line 15 int(1) Deprecated: current(): Calling current() on an object is deprecated in /in/5e6Ok on line 16 int(1) Deprecated: next(): Calling next() on an object is deprecated in /in/5e6Ok on line 17 int(2) Deprecated: prev(): Calling prev() on an object is deprecated in /in/5e6Ok on line 18 int(1) Deprecated: end(): Calling end() on an object is deprecated in /in/5e6Ok on line 19 int(6) WORKING: int(3) int(6)
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 7.0.0 - 7.0.30, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.30, 7.4.0 - 7.4.23, 8.0.0 - 8.0.11
BROKEN: int(1) int(1) int(2) int(1) int(6) WORKING: int(3) int(6)
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/5e6Ok on line 4
Process exited with code 255.
Output for 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/5e6Ok on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/5e6Ok on line 4
Process exited with code 255.

preferences:
72.19 ms | 542 KiB | 24 Q