3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo implements Serializable { public function jsonSerialize() { return [ 'title' => $this->title, 'parent' => $this->parent, ]; } } $f1 = new Foo(); $f1->title = 'Foo'; $f2 = new Foo(); $f2->title = 'Bar'; $f2->parent = $f1; echo json_encode($f2);

preferences:
76.73 ms | 402 KiB | 5 Q