3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = new DateTime('2012-07-01'); $interval = new DateInterval('P7D'); $end = new DateTime('2012-07-31'); $recurrences = 4; $iso = 'R4/2012-07-01T00:00:00Z/P7D'; // All of these periods are equivalent. $p = new DatePeriod($start, $interval, $recurrences); $p = new DatePeriod($start, $interval, $end); //$p = new DatePeriod($iso); foreach ($p as $d) { echo $d->format('d '); } echo "\n"; $p = \PHP_VERSION_ID >= 70107 ? clone $p : new \DatePeriod( $p->getStartDate(), new \DateInterval('P1D'), $p->getEndDate() ?: $p->recurrences - 1, (int) !$p->include_start_date ) ; foreach ($p as $d) { echo $d->format('d '); }
Output for 7.1.7 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
01 08 15 22 29 01 08 15 22 29
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 01 08 15 22 29 01 08 15 22 29
Output for 5.6.5 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.6
01 08 15 22 29 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Output for 5.6.0 - 5.6.4
01 08 15 22 29 Fatal error: Call to undefined method DatePeriod::getStartDate() in /in/agfao on line 23
Process exited with code 255.

preferences:
236.98 ms | 401 KiB | 291 Q