3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getIntervals($start_date, $end_date, $period) { $period_formats = array( 'day' => 'Y-m-d', 'week' => 'Y-W', 'month' => 'Y-m', 'year' => 'Y' ); $start = new DateTime($start_date); if($period != 'day') { $start->modify('first day of this '.$period); } $end = new DateTime($end_date); if($period != 'day') { $end->modify('first day of next '.$period); } $interval = DateInterval::createFromDateString('1 '.$period); $period = new DatePeriod($start, $interval, $end); foreach ($period as $dt) { echo "pf: ".$period_formats[$period]; echo $dt->format($period_formats[$period]) . "<br>\n"; } } getIntervals('2014-06-01', '2014-10-18', 'day'); ?>
Output for git.master, git.master_jit
Fatal error: Uncaught TypeError: Illegal offset type in /in/SR7oD:21 Stack trace: #0 /in/SR7oD(25): getIntervals('2014-06-01', '2014-10-18', Object(DatePeriod)) #1 {main} thrown in /in/SR7oD on line 21
Process exited with code 255.
Output for rfc.property-hooks
Fatal error: Uncaught TypeError: Cannot access offset of type object on array in /in/SR7oD:21 Stack trace: #0 /in/SR7oD(25): getIntervals('2014-06-01', '2014-10-18', Object(DatePeriod)) #1 {main} thrown in /in/SR7oD on line 21
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
49.61 ms | 401 KiB | 8 Q