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