3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = new DateTimeImmutable('2012-07-01'); $end = new DateTimeImmutable('2012-07-31'); $interval = new DateInterval('P7D'); $recurrences = 4; $periodWithRecurrences = new DatePeriod($start, $interval, $recurrences); echo "With recurrences:\n"; foreach ($periodWithRecurrences as $r) { printf("start=%s\n", $periodWithRecurrences->start->format("Y-m-d H:i:s")); printf("current=%s\n", $periodWithRecurrences->current->format("Y-m-d H:i:s")); printf("end=%s\n", $periodWithRecurrences->end ? $periodWithRecurrences->end->format("Y-m-d H:i:s") : "null"); printf("interval=%s\n", $periodWithRecurrences->interval->format("P%r%yY%mM%dDT%hH%iM%sS (%ad)")); printf("recurrences=%s\n", $periodWithRecurrences->recurrences); printf("include_start_date=%s\n", $periodWithRecurrences->include_start_date); break; } $periodWithoutRecurrences = new DatePeriod($start, $interval, $end); echo "\nWithout recurrences:\n"; foreach ($periodWithoutRecurrences as $r) { printf("start=%s\n", $periodWithoutRecurrences->start->format("Y-m-d H:i:s")); printf("current=%s\n", $periodWithoutRecurrences->current->format("Y-m-d H:i:s")); printf("end=%s\n", $periodWithoutRecurrences->end ? $periodWithoutRecurrences->end->format("Y-m-d H:i:s") : "null"); printf("interval=%s\n", $periodWithoutRecurrences->interval->format("P%r%yY%mM%dDT%hH%iM%sS (%ad)")); printf("recurrences=%s\n", $periodWithoutRecurrences->recurrences); printf("include_start_date=%s\n", $periodWithoutRecurrences->include_start_date); break; }
Output for git.master, git.master_jit, rfc.property-hooks
With recurrences: start=2012-07-01 00:00:00 Fatal error: Uncaught Error: Call to a member function format() on null in /in/iGAV1:13 Stack trace: #0 {main} thrown in /in/iGAV1 on line 13
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:
87.45 ms | 401 KiB | 8 Q