3v4l.org

run code in 300+ PHP versions simultaneously
<?php function dumpMappedRow($mappedRow) { var_dump([ 'created' => $mappedRow['created']->format(DateTime::ISO8601), 'modified' => $mappedRow['modified']->format(DateTime::ISO8601) ]); } function mutableDemo() { $date = DateTime::createFromFormat("Y-m-d", "2015-11-24"); $mappedRow['created'] = $date; $mappedRow['modified'] = $date; dumpMappedRow($mappedRow); $mappedRow['modified']->setDate(2016, 12, 25); dumpMappedRow($mappedRow); if ($mappedRow['created']->getTimestamp() === $mappedRow['modified']->getTimestamp()) { echo "\nCreated and Modified are set to the same value."; } } function immutableDemo() { $date = DateTimeImmutable::createFromFormat("Y-m-d", "2015-11-24"); $mappedRow['created'] = $date; $mappedRow['modified'] = $date; dumpMappedRow($mappedRow); // This actually returns a new object rather than modifying the existing one. $mappedRow['modified'] = $mappedRow['modified']->setDate(2016, 12, 25); 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();
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { ["created"]=> string(24) "2015-11-24T21:23:37+0100" ["modified"]=> string(24) "2015-11-24T21:23:37+0100" } array(2) { ["created"]=> string(24) "2016-12-25T21:23:37+0100" ["modified"]=> string(24) "2016-12-25T21:23:37+0100" } Created and Modified are set to the same value. ========== array(2) { ["created"]=> string(24) "2015-11-24T21:23:37+0100" ["modified"]=> string(24) "2015-11-24T21:23:37+0100" } array(2) { ["created"]=> string(24) "2015-11-24T21:23:37+0100" ["modified"]=> string(24) "2016-12-25T21:23:37+0100" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
76.98 ms | 402 KiB | 8 Q