3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php var_dump(DateTimeImmutable::createFromMutable(new DateTime('midnight'))); var_dump(DateTimeImmutable::createFromMutable(new DateTimeImmutable('midnight')));
based on sHrQ2

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for Typed properties v2
object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2015-09-24 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Warning: DateTimeImmutable::createFromMutable() expects parameter 1 to be DateTime, object given in /in/3IrR6 on line 4 NULL
Output for Arrow functions
object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2015-09-24 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Warning: DateTimeImmutable::createFromMutable() expects parameter 1 to be DateTime, object given in /in/3IrR6 on line 4 NULL
Output for Object typehint
object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2015-09-24 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Warning: DateTimeImmutable::createFromMutable() expects parameter 1 to be DateTime, object given in /in/3IrR6 on line 4 NULL
Output for Array change keys
object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2015-09-24 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Warning: DateTimeImmutable::createFromMutable() expects parameter 1 to be DateTime, object given in /in/3IrR6 on line 4 NULL
Output for Lexical anon
object(DateTimeImmutable)#2 (3) { ["date"]=> string(26) "2015-09-24 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } Warning: DateTimeImmutable::createFromMutable() expects parameter 1 to be DateTime, object given in /in/3IrR6 on line 4 NULL

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