3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('display_errors', 'On'); error_reporting(E_ALL); try { echo 'JSON decode of null: ' . json_decode(null) . PHP_EOL; if (json_last_error() !== JSON_ERROR_NONE) { echo 'Last JSON error: ' . safe_json_last_error_msg() . PHP_EOL; } } catch (Throwable $t) { echo 'Error from JSON decode of null: ' . $t->getMessage() . PHP_EOL; } try { echo 'JSON decode of empty string: ' . json_decode('') . PHP_EOL; if (json_last_error() !== JSON_ERROR_NONE) { echo 'Last JSON error: ' . safe_json_last_error_msg() . PHP_EOL; } } catch (Throwable $t) { echo 'Error from JSON decode of empty string: ' . $t->getMessage() . PHP_EOL; } function safe_json_last_error_msg() { if (function_exists('json_last_error_msg')) { return json_last_error_msg(); } switch (json_last_error()) { case JSON_ERROR_NONE: return 'No error'; case JSON_ERROR_DEPTH: return 'Maximum stack depth exceeded'; case JSON_ERROR_STATE_MISMATCH: return 'State mismatch (invalid or malformed JSON)'; case JSON_ERROR_CTRL_CHAR: return 'Control character error, possibly incorrectly encoded'; case JSON_ERROR_SYNTAX: return 'Syntax error'; case JSON_ERROR_UTF8: return 'Malformed UTF-8 characters, possibly incorrectly encoded'; default: return 'Unknown error'; } }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /in/aqapV on line 7 JSON decode of null: Last JSON error: Syntax error JSON decode of empty string: Last JSON error: Syntax error

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
26.13 ms | 406 KiB | 5 Q