3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { var $dateTime; var $string; public function __construct() { $this->dateTime = new \DateTime(); $this->string = 'foo'; } } $obj1 = new Foo(); $obj2 = clone $obj1; $obj1->string = 'foo bar'; $obj1->dateTime->add(new \DateInterval('1PD')); var_dump($obj1, $obj2);
based on GZbGT
Output for 7.0.0 - 7.3.0rc3
Fatal error: Uncaught Exception: DateInterval::__construct(): Unknown or bad format (1PD) in /in/hnpku:17 Stack trace: #0 /in/hnpku(17): DateInterval->__construct('1PD') #1 {main} thrown in /in/hnpku on line 17
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught exception 'Exception' with message 'DateInterval::__construct: Invalid interval (1PD)' in /in/hnpku:17 Stack trace: #0 /in/hnpku(17): DateInterval->__construct() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Fatal error: Uncaught exception 'Exception' with message 'DateInterval::__construct(): Unknown or bad format (1PD)' in /in/hnpku:17 Stack trace: #0 /in/hnpku(17): DateInterval->__construct('1PD') #1 {main} thrown in /in/hnpku on line 17
Process exited with code 255.