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 objectDemo() { $date = new DateTime(); $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 stringDemo() { $date = "2015-09-24T21:17:43+0200"; $mappedRow['created'] = $date; $mappedRow['modified'] = $date; var_dump($mappedRow); $mappedRow['modified'] = "2015-11-24T21:17:43+0200"; var_dump($mappedRow); if ($mappedRow['created']->getTimestamp() === $mappedRow['modified']->getTimestamp()) { echo "\nCreated and Modified are set to the same value."; } } objectDemo(); echo "\n\n==========\n\n"; stringDemo();
based on PHfQI
Output for 7.0.0 - 7.2.0
array(2) { ["created"]=> string(24) "2015-09-24T21:19:28+0200" ["modified"]=> string(24) "2015-09-24T21:19:28+0200" } array(2) { ["created"]=> string(24) "2015-11-15T21:19:28+0100" ["modified"]=> string(24) "2015-11-15T21:19:28+0100" } Created and Modified are set to the same value. ========== array(2) { ["created"]=> string(24) "2015-09-24T21:17:43+0200" ["modified"]=> string(24) "2015-09-24T21:17:43+0200" } array(2) { ["created"]=> string(24) "2015-09-24T21:17:43+0200" ["modified"]=> string(24) "2015-11-24T21:17:43+0200" } Fatal error: Uncaught Error: Call to a member function getTimestamp() on string in /in/Wr8UT:43 Stack trace: #0 /in/Wr8UT(51): stringDemo() #1 {main} thrown in /in/Wr8UT on line 43
Process exited with code 255.
Output for 5.6.0 - 5.6.28
array(2) { ["created"]=> string(24) "2015-09-24T21:19:28+0200" ["modified"]=> string(24) "2015-09-24T21:19:28+0200" } array(2) { ["created"]=> string(24) "2015-11-15T21:19:28+0100" ["modified"]=> string(24) "2015-11-15T21:19:28+0100" } Created and Modified are set to the same value. ========== array(2) { ["created"]=> string(24) "2015-09-24T21:17:43+0200" ["modified"]=> string(24) "2015-09-24T21:17:43+0200" } array(2) { ["created"]=> string(24) "2015-09-24T21:17:43+0200" ["modified"]=> string(24) "2015-11-24T21:17:43+0200" } Fatal error: Call to a member function getTimestamp() on string in /in/Wr8UT on line 43
Process exited with code 255.
Output for 5.4.0 - 5.5.38
array(2) { ["created"]=> string(24) "2015-09-24T21:19:28+0200" ["modified"]=> string(24) "2015-09-24T21:19:28+0200" } array(2) { ["created"]=> string(24) "2015-11-15T21:19:28+0100" ["modified"]=> string(24) "2015-11-15T21:19:28+0100" } Created and Modified are set to the same value. ========== array(2) { ["created"]=> string(24) "2015-09-24T21:17:43+0200" ["modified"]=> string(24) "2015-09-24T21:17:43+0200" } array(2) { ["created"]=> string(24) "2015-09-24T21:17:43+0200" ["modified"]=> string(24) "2015-11-24T21:17:43+0200" } Fatal error: Call to a member function getTimestamp() on a non-object in /in/Wr8UT on line 43
Process exited with code 255.