3v4l.org

run code in 300+ PHP versions simultaneously
<?php function encode($value, int $flags = 0) { $flags = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | ($flags & 0) | (defined('JSON_PRESERVE_ZERO_FRACTION') ? JSON_PRESERVE_ZERO_FRACTION : 0); // since PHP 5.6.6 & PECL JSON-C 1.3.7 $json = json_encode($value, $flags); if ($error = json_last_error()) { throw new Exception(json_last_error_msg(), $error); } if (PHP_VERSION_ID < 70100) { $json = str_replace(["\u{2028}", "\u{2029}"], ['\u2028', '\u2029'], $json); } return $json; } echo encode((object)[1 => 2]);
Output for git.master, git.master_jit, rfc.property-hooks
{"1":2}

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:
34.48 ms | 401 KiB | 8 Q