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('+1D'); $demo->echo();
Output for 7.0.28 - 7.3.0rc3
30/10/2018 10:29:15 Warning: DateTime::add() expects parameter 1 to be DateInterval, string given in /in/PvXCL on line 13 30/10/2018 10:29:15
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/PvXCL on line 7
Process exited with code 255.