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]);

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
154.84 ms | 2137 KiB | 9 Q