3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Period implements JsonSerializable { private $startDate; private $endDate; public function __construct() { $this->startDate = new DateTimeImmutable('2015-04-03'); $this->endDate = new DateTimeImmutable('2015-05-03'); } public function jsonSerialize() { return [ 'startDate' => $this->startDate, 'endDate' => $this->endDate, ]; } } $period = new Period(); var_dump(json_decode(json_encode($period)));

preferences:
49.95 ms | 402 KiB | 5 Q