3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php for($i = new \DateTime(); $i < new \DateTime('+ 50 years'); $i->add(new \DateInterval('P1Y'))){ echo $i->format('Y') . "<br>\n"; }
Output for 7.1.0 - 7.1.2, 7.1.4 - 7.2.2
2018<br> 2019<br> 2020<br> 2021<br> 2022<br> 2023<br> 2024<br> 2025<br> 2026<br> 2027<br> 2028<br> 2029<br> 2030<br> 2031<br> 2032<br> 2033<br> 2034<br> 2035<br> 2036<br> 2037<br> 2038<br> 2039<br> 2040<br> 2041<br> 2042<br> 2043<br> 2044<br> 2045<br> 2046<br> 2047<br> 2048<br> 2049<br> 2050<br> 2051<br> 2052<br> 2053<br> 2054<br> 2055<br> 2056<br> 2057<br> 2058<br> 2059<br> 2060<br> 2061<br> 2062<br> 2063<br> 2064<br> 2065<br> 2066<br> 2067<br> 2068<br>
Output for 5.3.0 - 5.6.30, hhvm-3.10.1 - 3.22.0, 7.0.0 - 7.0.27, 7.1.3
2018<br> 2019<br> 2020<br> 2021<br> 2022<br> 2023<br> 2024<br> 2025<br> 2026<br> 2027<br> 2028<br> 2029<br> 2030<br> 2031<br> 2032<br> 2033<br> 2034<br> 2035<br> 2036<br> 2037<br> 2038<br> 2039<br> 2040<br> 2041<br> 2042<br> 2043<br> 2044<br> 2045<br> 2046<br> 2047<br> 2048<br> 2049<br> 2050<br> 2051<br> 2052<br> 2053<br> 2054<br> 2055<br> 2056<br> 2057<br> 2058<br> 2059<br> 2060<br> 2061<br> 2062<br> 2063<br> 2064<br> 2065<br> 2066<br> 2067<br>
Output for 5.2.2 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/KrLrb on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/KrLrb on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/KrLrb on line 2 2018<br> Fatal error: Call to undefined method DateTime::add() in /in/KrLrb on line 2
Process exited with code 255.
Output for 5.2.0 - 5.2.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/KrLrb on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/KrLrb on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/KrLrb on line 2
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/KrLrb on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/KrLrb on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/KrLrb on line 2 Fatal error: Class 'DateTime' not found in /in/KrLrb on line 2
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/KrLrb on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/KrLrb on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/KrLrb on line 2 Fatal error: Cannot instantiate non-existent class: datetime in /in/KrLrb on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/KrLrb on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/KrLrb on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/KrLrb on line 2 Fatal error: Cannot instantiate non-existent class: datetime in /in/KrLrb on line 2