3v4l.org

run code in 500+ PHP versions simultaneously
<?php echo "Start\n"; var_dump(json_last_error()); echo "\n"; echo "Error without flag\n"; json_decode('{'); var_dump(json_last_error()); echo "\n"; echo "Clear error\n"; json_decode('true'); // clear error var_dump(json_last_error()); echo "\n"; echo "Error with flag\n"; try { json_decode('{', flags: JSON_THROW_ON_ERROR); } catch (\JsonException $e) { echo $e->getMessage(), "\n"; } var_dump(json_last_error()); echo "\n"; echo "Set different error\n"; json_decode(str_repeat('[', 1000)); var_dump(json_last_error()); echo "and check that it is not overwritten when JSON_THROW_ON_ERROR is set\n"; try { json_decode('{', flags: JSON_THROW_ON_ERROR); } catch (\JsonException $e) { echo $e->getMessage(), "\n"; } var_dump(json_last_error());
Output for git.master, git.master_jit
Start int(0) Error without flag int(4) Clear error int(0) Error with flag Syntax error near location 1:2 int(0) Set different error int(1) and check that it is not overwritten when JSON_THROW_ON_ERROR is set Syntax error near location 1:2 int(1)

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:
40.05 ms | 2809 KiB | 4 Q