3v4l.org

run code in 500+ PHP versions simultaneously
<?php class MyDTI extends DateTimeImmutable { public $tag = 'immutable-tag'; private $secret = 'i-secret'; public function getSecret() { return $this->secret; } } $i = new MyDTI('2015-11-20 09:00:00'); $r = $i->add(new DateInterval('P1D')); echo get_class($r) . "|" . $r->format('Y-m-d') . "|" . (isset($r->tag)?$r->tag:'NONE') . "|" . ((method_exists($r,'getSecret'))?$r->getSecret():'NOSEC') . "\n"; $r2 = $i->setDate(2015,11,21); echo get_class($r2) . "|" . (isset($r2->tag)?$r2->tag:'NONE') . "\n"; class MyDT extends DateTime { public $tag='mt'; private $secret='ms'; public function getSecret(){return $this->secret;} } $m = new MyDT('2015-11-20 09:00:00'); $c = clone $m; $c->add(new DateInterval('P1D')); echo get_class($c) . "|" . $c->format('Y-m-d') . "|" . $c->tag . "|" . $c->getSecret() . "\n";
Output for master
MyDTI|2015-11-21|immutable-tag|i-secret MyDTI|immutable-tag MyDT|2015-11-21|mt|ms

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:
15.62 ms | 1164 KiB | 7 Q