3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $startDate = DateTimeImmutable::createFromFormat('Y-m-d', '2018-01-01'); $dateInterval = new DateInterval('P1D'); $dateRange = new DatePeriod($startDate, $dateInterval, new DateTimeImmutable); foreach($dateRange as $date) { if (in_array($date->format('w'), [0, 6])) { echo 'weekend'; continue; } echo $date->current->format('Y-m-d'); }
Output for 7.0.30 - 7.3.0alpha1
Notice: Undefined property: DateTimeImmutable::$current in /in/ossXj on line 13 Fatal error: Uncaught Error: Call to a member function format() on null in /in/ossXj:13 Stack trace: #0 {main} thrown in /in/ossXj on line 13
Process exited with code 255.
Output for hhvm-3.22.0
Notice: Undefined property: DateTimeImmutable::$current in /in/ossXj on line -1 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function format() on a non-object (null)' in /in/ossXj:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Notice: Undefined property: DateTimeImmutable::$current in /in/ossXj on line 13 Fatal error: Uncaught exception 'BadMethodCallException' with message 'Call to a member function format() on a non-object (null)' in /in/ossXj:13 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.30
Notice: Undefined property: DateTimeImmutable::$current in /in/ossXj on line 13 Fatal error: Call to a member function format() on null in /in/ossXj on line 13
Process exited with code 255.