3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Demo { public function __construct(DateTimeInterface $dateTime) { $this->date = $dateTime; } public function getDateTime(): DateTimeInterface { return $this->date; } public function echo() { echo $this->date->format("d/m/Y h:i:s"); } } $demo = new Demo(new DateTime()); $demo->echo()."\n"; $demo->getDateTime()->add(new DateTimeInterval('+1D')); $demo->echo();
based on PvXCL
Output for 7.0.28 - 7.3.0rc3
30/10/2018 10:29:35 Fatal error: Uncaught Error: Class 'DateTimeInterval' not found in /in/CPQGI:13 Stack trace: #0 {main} thrown in /in/CPQGI on line 13
Process exited with code 255.
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/CPQGI on line 7
Process exited with code 255.