3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo implements JsonSerializable { private $thing; public function __construct($thing) { $this->thing = $thing; } public function jsonSerialize() { return [ 'thing' => $this->thing, ]; } } $foo = new Foo('Foo Bar'); echo json_encode(['the_foo' => $foo]);

preferences:
52.74 ms | 402 KiB | 5 Q