3v4l.org

run code in 300+ PHP versions simultaneously
<?php class JsonResponse { const DEFAULT_ENCODING_OPTIONS = 15; protected $encodingOptions = self::DEFAULT_ENCODING_OPTIONS; public function __construct($data = null) { $data = json_encode($data, $this->encodingOptions); } } class JsonSerializableObject implements \JsonSerializable { public function jsonSerialize() { throw new \Exception('This error is expected'); } } $serializable = new JsonSerializableObject(); new JsonResponse($serializable);

preferences:
68.51 ms | 402 KiB | 5 Q