3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = 'invalid json test'; try { $array = json_decode($json, true, 512, JSON_THROW_ON_ERROR); printf('Valid JSON output: %s', print_r($array, true)); } catch (\JsonException $exception) { printf('Invalid JSON input: %s', print_r($exception, true)); }

preferences:
30.64 ms | 402 KiB | 5 Q