3v4l.org

run code in 500+ PHP versions simultaneously
<?php $fixtures = [ // Not valid 'foo', '{foo: bar}', "'{'foo': 'bar'}", '{...}', // Valid '"foo"', '1', '{"foo": "bar"}', ]; foreach ($fixtures as $string) { if (json_validate($string)) { echo sprintf('YES, >%s< is a valid JSON string', $string).PHP_EOL; echo 'decoded: '. var_export(json_decode($string), true).PHP_EOL; } else { echo sprintf('NO, >%s< is NOT a valid JSON string: %s', $string, json_last_error_msg()). PHP_EOL; } }
Output for git.master, git.master_jit, rfc.property-hooks
NO, >foo< is NOT a valid JSON string: Syntax error NO, >{foo: bar}< is NOT a valid JSON string: Syntax error NO, >'{'foo': 'bar'}< is NOT a valid JSON string: Syntax error NO, >{...}< is NOT a valid JSON string: Syntax error YES, >"foo"< is a valid JSON string decoded: 'foo' YES, >1< is a valid JSON string decoded: 1 YES, >{"foo": "bar"}< is a valid JSON string decoded: (object) array( 'foo' => 'bar', )

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:
51.16 ms | 859 KiB | 4 Q