3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function dumpMappedRow($mappedRow) { var_dump([ 'created' => $mappedRow['created']->format(DateTime::ISO8601), 'modified' => $mappedRow['modified']->format(DateTime::ISO8601) ]); } function mutableDemo() { $date = DateTime::createFromFormat("Ymd", "2015-11-24"); $mappedRow['created'] = $date; $mappedRow['modified'] = $date; dumpMappedRow($mappedRow); $mappedRow['modified']->setDate("2015", "11", "15"); dumpMappedRow($mappedRow); if ($mappedRow['created']->getTimestamp() === $mappedRow['modified']->getTimestamp()) { echo "\nCreated and Modified are set to the same value."; } } function immutableDemo() { $date = DateTimeImmutable::createFromFormat("Ymd", "2015-11-24"); $mappedRow['created'] = $date; $mappedRow['modified'] = $date; dumpMappedRow($mappedRow); $mappedRow['modified']->setDate("2015", "11", "15"); dumpMappedRow($mappedRow); if ($mappedRow['created']->getTimestamp() === $mappedRow['modified']->getTimestamp()) { echo "\nCreated and Modified are set to the same value."; } } mutableDemo(); echo "\n\n==========\n\n"; immutableDemo();
based on u5Rv8
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to a member function format() on boolean in /in/sYanh:6 Stack trace: #0 /in/sYanh(18): dumpMappedRow(Array) #1 /in/sYanh(49): mutableDemo() #2 {main} thrown in /in/sYanh on line 6
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Fatal error: Call to a member function format() on boolean in /in/sYanh on line 6
Process exited with code 255.
Output for 5.4.1 - 5.5.35
Fatal error: Call to a member function format() on a non-object in /in/sYanh on line 6
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/sYanh on line 5
Process exited with code 255.