3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Recursion implements JsonSerializable { public function __construct() { $this->cnt = 500; } public function jsonSerialize() { if ($this->cnt < 1) { return null; } $this->cnt--; var_dump($this->cnt); return array($this->cnt => $this); } } var_dump(json_encode(new Recursion()));
based on QsYQX
Output for 5.5.0 - 5.6.28, 7.0.0 - 7.1.0
int(499) int(498) bool(false)
Output for hhvm-3.10.0 - 3.12.0
int(499) int(498) int(497) bool(false)
Output for 5.4.4 - 5.4.45
int(499) int(498) Warning: json_encode(): recursion detected in /in/BFp1G on line 19 string(20) "{"499":{"498":null}}"
Output for 5.4.0 - 5.4.3
int(499) int(498) int(497) int(496) int(495) int(494) int(493) int(492) int(491) int(490) int(489) int(488) int(487) int(486) int(485) int(484) int(483) int(482) int(481) int(480) int(479) int(478) int(477) int(476) int(475) int(474) int(473) int(472) int(471) int(470) int(469) int(468) int(467) int(466) int(465) int(464) int(463) int(462) int(461) int(460) int(459) int(458) int(457) int(456) int(455) int(454) int(453) int(452) int(451) int(450) int(449) int(448) int(447) int(446) int(445) int(444) int(443) int(442) int(441) int(440) int(439) int(438) int(437) int(436) int(435) int(434) int(433) int(432) int(431) int(430) int(429) int(428) int(427) int(426) int(425) int(424) int(423) int(422) int(421) int(420) int(419) int(418) int(417) int(416) int(415) int(414) int(413) int(412) int(411) int(410) int(409) int(408) int(407) int(406) int(405) int(404) int(403) int(402) int(401) int(400) int(399) int(398) int(397) int(396) int(395) int(394) int(393) int(392) int(391) int(390) int(389) int(388) int(387) int(386) int(385) int(384) int(383) int(382) int(381) int(380) int(379) int(378) int(377) int(376) int(375) int(374) int(373) int(372) int(371) int(370) int(369) int(368) int(367) int(366) int(365) int(364) int(363) int(362) int(361) int(360) int(359) int(358) int(357) int(356) int(355) int(354) int(353) int(352) int(351) int(350) int(349) int(348) int(347) int(346) int(345) int(344) int(343) int(342) int(341) int(340) int(339) int(338) int(337) int(336) int(335) int(334) int(333) int(332) int(331) int(330) int(329) int(328) int(327) int(326) int(325) int(324) int(323) int(322) int(321) int(320) int(319) int(318) int(317) int(316) int(315) int(314) int(313) int(312) int(311) int(310) int(309) int(308) int(307) int(306) int(305) int(304) int(303) int(302) int(301) int(300) int(299) int(298) int(297) int(296) int(295) int(294) int(293) int(292) int(291) int(290) int(289) int(288) int(287) int(286) int(285) int(284) int(283) int(282) int(281) int(280) int(279) int(278) int(277) int(276) int(275) int(274) int(273) int(272) int(271) int(270) int(269) int(268) int(267) int(266) int(265) int(264) int(263) int(262) int(261) int(260) int(259) int(258) int(257) int(256) int(255) int(254) int(253) int(252) int(251) int(250) int(249) int(248) int(247) int(246) int(245) int(244) int(243) int(242) int(241) int(240) int(239) int(238) int(237) int(236) int(235) int(234) int(233) int(232) int(231) int(230) int(229) int(228) int(227) int(226) int(225) int(224) int(223) int(222) int(221) int(220) int(219) int(218) int(217) int(216) int(215) int(214) int(213) int(212) int(211) int(210) int(209) int(208) int(207) int(206) int(205) int(204) int(203) int(202) int(201) int(200) int(199) int(198) int(197) int(196) int(195) int(194) int(193) int(192) int(191) int(190) int(189) int(188) int(187) int(186) int(185) int(184) int(183) int(182) int(181) int(180) int(179) int(178) int(177) int(176) int(175) int(174) int(173) int(172) int(171) int(170) int(169) int(168) int(167) int(166) int(165) int(164) int(163) int(162) int(161) int(160) int(159) int(158) int(157) int(156) int(155) int(154) int(153) int(152) int(151) int(150) int(149) int(148) int(147) int(146) int(145) int(144) int(143) int(142) int(141) int(140) int(139) int(138) int(137) int(136) int(135) int(134) int(133) int(132) int(131) int(130) int(129) int(128) int(127) int(126) int(125) int(124) int(123) int(122) int(121) int(120) int(119) int(118) int(117) int(116) int(115) int(114) int(113) int(112) int(111) int(110) int(109) int(108) int(107) int(106) int(105) int(104) int(103) int(102) int(101) int(100) int(99) int(98) int(97) int(96) int(95) int(94) int(93) int(92) int(91) int(90) int(89) int(88) int(87) int(86) int(85) int(84) int(83) int(82) int(81) int(80) int(79) int(78) int(77) int(76) int(75) int(74) int(73) int(72) int(71) int(70) int(69) int(68) int(67) int(66) int(65) int(64) int(63) int(62) int(61) int(60) int(59) int(58) int(57) int(56) int(55) int(54) int(53) int(52) int(51) int(50) int(49) int(48) int(47) int(46) int(45) int(44) int(43) int(42) int(41) int(40) int(39) int(38) int(37) int(36) int(35) int(34) int(33) int(32) int(31) int(30) int(29) int(28) int(27) int(26) int(25) int(24) int(23) int(22) int(21) int(20) int(19) int(18) int(17) int(16) int(15) int(14) int(13) int(12) int(11) int(10) int(9) int(8) int(7) int(6) int(5) int(4) int(3) int(2) int(1) int(0) string(3890) "{"499":{"498":{"497":{"496":{"495":{"494":{"493":{"492":{"491":{"490":{"489":{"488":{"487":{"486":{"485":{"484":{"483":{"482":{"481":{"480":{"479":{"478":{"477":{"476":{"475":{"474":{"473":{"472":{"471":{"470":{"469":{"468":{"467":{"466":{"465":{"464":{"463":{"462":{"461":{"460":{"459":{"458":{"457":{"456":{"455":{"454":{"453":{"452":{"451":{"450":{"449":{"448":{"447":{"446":{"445":{"444":{"443":{"442":{"441":{"440":{"439":{"438":{"437":{"436":{"435":{"434":{"433":{"432":{"431":{"430":{"429":{"428":{"427":{"426":{"425":{"424":{"423":{"422":{"421":{"420":{"419":{"418":{"417":{"416":{"415":{"414":{"413":{"412":{"411":{"410":{"409":{"408":{"407":{"406":{"405":{"404":{"403":{"402":{"401":{"400":{"399":{"398":{"397":{"396":{"395":{"394":{"393":{"392":{"391":{"390":{"389":{"388":{"387":{"386":{"385":{"384":{"383":{"382":{"381":{"380":{"379":{"378":{"377":{"376":{"375":{"374":{"373":{"372":{"371":{"370":{"369":{"368":{"367":{"366":{"365":{"364":{"363":{"362":{"361":{"360":{"359":{"358":{"357":{"356":{"355":{"354":{"353":{"352":{"351":{"350":{"349":{"348":{"347":{"346":{"345":{"344":{"343":{"342":{"341":{"340":{"339":{"338":{"337":{"336":{"335":{"334":{"333":{"332":{"331":{"330":{"329":{"328":{"327":{"326":{"325":{"324":{"323":{"322":{"321":{"320":{"319":{"318":{"317":{"316":{"315":{"314":{"313":{"312":{"311":{"310":{"309":{"308":{"307":{"306":{"305":{"304":{"303":{"302":{"301":{"300":{"299":{"298":{"297":{"296":{"295":{"294":{"293":{"292":{"291":{"290":{"289":{"288":{"287":{"286":{"285":{"284":{"283":{"282":{"281":{"280":{"279":{"278":{"277":{"276":{"275":{"274":{"273":{"272":{"271":{"270":{"269":{"268":{"267":{"266":{"265":{"264":{"263":{"262":{"261":{"260":{"259":{"258":{"257":{"256":{"255":{"254":{"253":{"252":{"251":{"250":{"249":{"248":{"247":{"246":{"245":{"244":{"243":{"242":{"241":{"240":{"239":{"238":{"237":{"236":{"235":{"234":{"233":{"232":{"231":{"230":{"229":{"228":{"227":{"226":{"225":{"224":{"223":{"222":{"221":{"220":{"219":{"218":{"217":{"216":{"215":{"214":{"213":{"212":{"211":{"210":{"209":{"208":{"207":{"206":{"205":{"204":{"203":{"202":{"201":{"200":{"199":{"198":{"197":{"196":{"195":{"194":{"193":{"192":{"191":{"190":{"189":{"188":{"187":{"186":{"185":{"184":{"183":{"182":{"181":{"180":{"179":{"178":{"177":{"176":{"175":{"174":{"173":{"172":{"171":{"170":{"169":{"168":{"167":{"166":{"165":{"164":{"163":{"162":{"161":{"160":{"159":{"158":{"157":{"156":{"155":{"154":{"153":{"152":{"151":{"150":{"149":{"148":{"147":{"146":{"145":{"144":{"143":{"142":{"141":{"140":{"139":{"138":{"137":{"136":{"135":{"134":{"133":{"132":{"131":{"130":{"129":{"128":{"127":{"126":{"125":{"124":{"123":{"122":{"121":{"120":{"119":{"118":{"117":{"116":{"115":{"114":{"113":{"112":{"111":{"110":{"109":{"108":{"107":{"106":{"105":{"104":{"103":{"102":{"101":{"100":{"99":{"98":{"97":{"96":{"95":{"94":{"93":{"92":{"91":{"90":{"89":{"88":{"87":{"86":{"85":{"84":{"83":{"82":{"81":{"80":{"79":{"78":{"77":{"76":{"75":{"74":{"73":{"72":{"71":{"70":{"69":{"68":{"67":{"66":{"65":{"64":{"63":{"62":{"61":{"60":{"59":{"58":{"57":{"56":{"55":{"54":{"53":{"52":{"51":{"50":{"49":{"48":{"47":{"46":{"45":{"44":{"43":{"42":{"41":{"40":{"39":{"38":{"37":{"36":{"35":{"34":{"33":{"32":{"31":{"30":{"29":{"28":{"27":{"26":{"25":{"24":{"23":{"22":{"21":{"20":{"19":{"18":{"17":{"16":{"15":{"14":{"13":{"12":{"11":{"10":{"9":{"8":{"7":{"6":{"5":{"4":{"3":{"2":{"1":[null]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}"
Output for 5.0.5 - 5.3.29
Fatal error: Interface 'JsonSerializable' not found in /in/BFp1G on line 3
Process exited with code 255.
Output for 5.0.0 - 5.0.4
Fatal error: Class 'JsonSerializable' not found in /in/BFp1G on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/BFp1G on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting '{' in /in/BFp1G on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/BFp1G on line 3
Process exited with code 255.