3v4l.org

run code in 300+ PHP versions simultaneously
<?php $invalid = '{"test":"foo}'; $valid = '[]'; try { json_decode($invalid, true); // this fails silently json_decode($valid, true, 512, JSON_THROW_ON_ERROR); // Which is what Safe does to check if it needs to throw an exception if (json_last_error() !== JSON_ERROR_NONE) { var_dump('With the flag', json_last_error_msg()); } json_decode($valid, true); // Which is what Safe does to check if it needs to throw an exception if (json_last_error() !== JSON_ERROR_NONE) { var_dump('Without the flag', json_last_error_msg()); } } catch (Throwable $e) { echo 'This should not even be triggered: ' . $e->getMessage() . PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
string(13) "With the flag" string(53) "Control character error, possibly incorrectly encoded"

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:
23.94 ms | 405 KiB | 5 Q