3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getSundays($y, $m) { return new DatePeriod( new DateTime("first Sunday of $y-$m"), DateInterval::createFromDateString('next sunday'), new DateTime("last day of $y-$m") ); } $days=""; foreach (getSundays(2016, 04) as $Sunday) { $days[] = $Sunday->format("d"); } var_dump($days);
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.26, 8.0.0 - 8.0.13, 8.1rc1 - rc3
Fatal error: Uncaught Error: [] operator not supported for strings in /in/DVYM5:14 Stack trace: #0 {main} thrown in /in/DVYM5 on line 14
Process exited with code 255.
Output for 5.5.0 - 5.5.37, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20
array(4) { [0]=> string(2) "03" [1]=> string(2) "10" [2]=> string(2) "17" [3]=> string(2) "24" }

preferences:
18.49 ms | 461 KiB | 5 Q