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()."<br>"; $demo->getDateTime()->add(new DateInterval('P1D')); $demo->echo();
based on NJp2X
Output for 7.0.28 - 7.3.0rc3
30/10/2018 10:31:3331/10/2018 10:31:33
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/ZmBSL on line 7
Process exited with code 255.