3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $period = new DatePeriod( new DateTime(date('Y-m-d', time())), new DateInterval('P1D'), new DateTime(date('Y-m-d', strtotime('+3 DAYS'))) ); foreach(array('foo', 'bar') as $a) { var_dump($a); foreach ($period as $date) { var_dump(date('d-m-Y', $date->getTimestamp())); } } ?>
Output for 5.3.4 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
string(3) "foo" string(10) "04-04-2014" string(10) "05-04-2014" string(10) "06-04-2014" string(3) "bar" string(10) "04-04-2014" string(10) "05-04-2014" string(10) "06-04-2014"
Output for 5.3.0 - 5.3.3
string(3) "foo" string(10) "04-04-2014" string(10) "06-04-2014" string(10) "07-04-2014" string(3) "bar"
Output for 5.0.0 - 5.2.17
Fatal error: Class 'DatePeriod' not found in /in/aBcEG on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: dateperiod in /in/aBcEG on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: dateperiod in /in/aBcEG on line 3