3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = new DateTimeImmutable('2012-07-01'); $interval = new DateInterval('P1D'); $periodWithRecurrences = new \DatePeriod($start, $interval, $start->add($interval)); foreach($periodWithRecurrences as $date) { echo $date->format('Y-m-d') . \PHP_EOL; } echo \PHP_EOL; $periodWithRecurrences = new DatePeriod($start, $interval, 0); foreach($periodWithRecurrences as $date) { echo $date->format('Y-m-d') . \PHP_EOL; }
Output for 8.3.16 - 8.3.25, 8.4.3 - 8.4.12
2012-07-01 Fatal error: Uncaught DateMalformedPeriodStringException: DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than 2147483640 in /in/ReWbN:13 Stack trace: #0 /in/ReWbN(13): DatePeriod->__construct(Object(DateTimeImmutable), Object(DateInterval), 0) #1 {main} thrown in /in/ReWbN on line 13
Process exited with code 255.
Output for 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
2012-07-01 Fatal error: Uncaught DateMalformedPeriodStringException: DatePeriod::__construct(): Recurrence count must be greater than 0 in /in/ReWbN:13 Stack trace: #0 /in/ReWbN(13): DatePeriod->__construct(Object(DateTimeImmutable), Object(DateInterval), 0) #1 {main} thrown in /in/ReWbN on line 13
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29
2012-07-01 Fatal error: Uncaught Exception: DatePeriod::__construct(): Recurrence count must be greater than 0 in /in/ReWbN:13 Stack trace: #0 /in/ReWbN(13): DatePeriod->__construct(Object(DateTimeImmutable), Object(DateInterval), 0) #1 {main} thrown in /in/ReWbN on line 13
Process exited with code 255.
Output for 7.2.19 - 7.2.33, 7.3.6 - 7.3.33, 7.4.0 - 7.4.33
2012-07-01 Fatal error: Uncaught Exception: DatePeriod::__construct(): The recurrence count '0' is invalid. Needs to be > 0 in /in/ReWbN:13 Stack trace: #0 /in/ReWbN(13): DatePeriod->__construct(Object(DateTimeImmutable), Object(DateInterval), 0) #1 {main} thrown in /in/ReWbN on line 13
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.18, 7.3.0 - 7.3.5
2012-07-01 2012-07-01

preferences:
145.52 ms | 412 KiB | 5 Q