3v4l.org

run code in 300+ PHP versions simultaneously
<?php ob_start(); //simulating a JSON output ?> { "date": { "epoch": "1413475200", "pretty": "07:00 PM IDT , אוקטובר 16, 2014", "day": 16, "month": 10, "year": 2014, "yday": 288, "hour": 19, "min": "00", "sec": 0, "isdst": "1", "monthname": "אוקטובר", "monthname_short": "אוק", "weekday_short": "חמישי", "weekday": "חמישי", "ampm": "PM", "tz_short": "IDT", "tz_long": "Asia/Jerusalem" }, "period": 8, "high": { "fahrenheit": "81", "celsius": "27" }, "low": { "fahrenheit": "65", "celsius": "18" }, "conditions": "בהיר", "icon": "clear", "icon_url": "http://icons.wxug.com/i/c/k/clear.gif", "skyicon": "", "pop": 0, "qpf_allday": { "in": 0, "mm": 0 }, "qpf_day": { "in": 0, "mm": 0 }, "qpf_night": { "in": 0, "mm": 0 }, "snow_allday": { "in": 0, "cm": 0 }, "snow_day": { "in": 0, "cm": 0 }, "snow_night": { "in": 0, "cm": 0 }, "maxwind": { "mph": 10, "kph": 16, "dir": "מע", "degrees": 265 }, "avewind": { "mph": 9, "kph": 14, "dir": "מע", "degrees": 265 }, "avehumidity": 56, "maxhumidity": 0, "minhumidity": 0 } <?php $sJSONBuffer = ob_get_contents(); ob_end_clean(); //$sJSONBuffer = utf8_encode($sJSONBuffer); $aJSONStruct = json_decode($sJSONBuffer, true); var_dump($aJSONStruct); //print($sJSONBuffer); //echo 'errore '.json_last_error().''."\n"; switch (json_last_error()) { case JSON_ERROR_NONE: echo ' - No errors'; break; case JSON_ERROR_DEPTH: echo ' - Maximum stack depth exceeded'; break; case JSON_ERROR_STATE_MISMATCH: echo ' - Underflow or the modes mismatch'; break; case JSON_ERROR_CTRL_CHAR: echo ' - Unexpected control character found'; break; case JSON_ERROR_SYNTAX: echo ' - Syntax error, malformed JSON'; break; case JSON_ERROR_UTF8: echo ' - Malformed UTF-8 characters, possibly incorrectly encoded'; break; default: echo ' - Unknown error'; break; } echo 'errore '.json_last_error_msg().''."\n"; ?>
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
array(20) { ["date"]=> array(17) { ["epoch"]=> string(10) "1413475200" ["pretty"]=> string(38) "07:00 PM IDT , אוקטובר 16, 2014" ["day"]=> int(16) ["month"]=> int(10) ["year"]=> int(2014) ["yday"]=> int(288) ["hour"]=> int(19) ["min"]=> string(2) "00" ["sec"]=> int(0) ["isdst"]=> string(1) "1" ["monthname"]=> string(14) "אוקטובר" ["monthname_short"]=> string(6) "אוק" ["weekday_short"]=> string(10) "חמישי" ["weekday"]=> string(10) "חמישי" ["ampm"]=> string(2) "PM" ["tz_short"]=> string(3) "IDT" ["tz_long"]=> string(14) "Asia/Jerusalem" } ["period"]=> int(8) ["high"]=> array(2) { ["fahrenheit"]=> string(2) "81" ["celsius"]=> string(2) "27" } ["low"]=> array(2) { ["fahrenheit"]=> string(2) "65" ["celsius"]=> string(2) "18" } ["conditions"]=> string(8) "בהיר" ["icon"]=> string(5) "clear" ["icon_url"]=> string(37) "http://icons.wxug.com/i/c/k/clear.gif" ["skyicon"]=> string(0) "" ["pop"]=> int(0) ["qpf_allday"]=> array(2) { ["in"]=> int(0) ["mm"]=> int(0) } ["qpf_day"]=> array(2) { ["in"]=> int(0) ["mm"]=> int(0) } ["qpf_night"]=> array(2) { ["in"]=> int(0) ["mm"]=> int(0) } ["snow_allday"]=> array(2) { ["in"]=> int(0) ["cm"]=> int(0) } ["snow_day"]=> array(2) { ["in"]=> int(0) ["cm"]=> int(0) } ["snow_night"]=> array(2) { ["in"]=> int(0) ["cm"]=> int(0) } ["maxwind"]=> array(4) { ["mph"]=> int(10) ["kph"]=> int(16) ["dir"]=> string(4) "מע" ["degrees"]=> int(265) } ["avewind"]=> array(4) { ["mph"]=> int(9) ["kph"]=> int(14) ["dir"]=> string(4) "מע" ["degrees"]=> int(265) } ["avehumidity"]=> int(56) ["maxhumidity"]=> int(0) ["minhumidity"]=> int(0) } - No errorserrore No error
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45
array(20) { ["date"]=> array(17) { ["epoch"]=> string(10) "1413475200" ["pretty"]=> string(38) "07:00 PM IDT , אוקטובר 16, 2014" ["day"]=> int(16) ["month"]=> int(10) ["year"]=> int(2014) ["yday"]=> int(288) ["hour"]=> int(19) ["min"]=> string(2) "00" ["sec"]=> int(0) ["isdst"]=> string(1) "1" ["monthname"]=> string(14) "אוקטובר" ["monthname_short"]=> string(6) "אוק" ["weekday_short"]=> string(10) "חמישי" ["weekday"]=> string(10) "חמישי" ["ampm"]=> string(2) "PM" ["tz_short"]=> string(3) "IDT" ["tz_long"]=> string(14) "Asia/Jerusalem" } ["period"]=> int(8) ["high"]=> array(2) { ["fahrenheit"]=> string(2) "81" ["celsius"]=> string(2) "27" } ["low"]=> array(2) { ["fahrenheit"]=> string(2) "65" ["celsius"]=> string(2) "18" } ["conditions"]=> string(8) "בהיר" ["icon"]=> string(5) "clear" ["icon_url"]=> string(37) "http://icons.wxug.com/i/c/k/clear.gif" ["skyicon"]=> string(0) "" ["pop"]=> int(0) ["qpf_allday"]=> array(2) { ["in"]=> int(0) ["mm"]=> int(0) } ["qpf_day"]=> array(2) { ["in"]=> int(0) ["mm"]=> int(0) } ["qpf_night"]=> array(2) { ["in"]=> int(0) ["mm"]=> int(0) } ["snow_allday"]=> array(2) { ["in"]=> int(0) ["cm"]=> int(0) } ["snow_day"]=> array(2) { ["in"]=> int(0) ["cm"]=> int(0) } ["snow_night"]=> array(2) { ["in"]=> int(0) ["cm"]=> int(0) } ["maxwind"]=> array(4) { ["mph"]=> int(10) ["kph"]=> int(16) ["dir"]=> string(4) "מע" ["degrees"]=> int(265) } ["avewind"]=> array(4) { ["mph"]=> int(9) ["kph"]=> int(14) ["dir"]=> string(4) "מע" ["degrees"]=> int(265) } ["avehumidity"]=> int(56) ["maxhumidity"]=> int(0) ["minhumidity"]=> int(0) } - No errors Fatal error: Call to undefined function json_last_error_msg() in /in/KL9XC on line 113
Process exited with code 255.
Output for 5.2.0 - 5.2.17
array(20) { ["date"]=> array(17) { ["epoch"]=> string(10) "1413475200" ["pretty"]=> string(38) "07:00 PM IDT , אוקטובר 16, 2014" ["day"]=> int(16) ["month"]=> int(10) ["year"]=> int(2014) ["yday"]=> int(288) ["hour"]=> int(19) ["min"]=> string(2) "00" ["sec"]=> int(0) ["isdst"]=> string(1) "1" ["monthname"]=> string(14) "אוקטובר" ["monthname_short"]=> string(6) "אוק" ["weekday_short"]=> string(10) "חמישי" ["weekday"]=> string(10) "חמישי" ["ampm"]=> string(2) "PM" ["tz_short"]=> string(3) "IDT" ["tz_long"]=> string(14) "Asia/Jerusalem" } ["period"]=> int(8) ["high"]=> array(2) { ["fahrenheit"]=> string(2) "81" ["celsius"]=> string(2) "27" } ["low"]=> array(2) { ["fahrenheit"]=> string(2) "65" ["celsius"]=> string(2) "18" } ["conditions"]=> string(8) "בהיר" ["icon"]=> string(5) "clear" ["icon_url"]=> string(37) "http://icons.wxug.com/i/c/k/clear.gif" ["skyicon"]=> string(0) "" ["pop"]=> int(0) ["qpf_allday"]=> array(2) { ["in"]=> int(0) ["mm"]=> int(0) } ["qpf_day"]=> array(2) { ["in"]=> int(0) ["mm"]=> int(0) } ["qpf_night"]=> array(2) { ["in"]=> int(0) ["mm"]=> int(0) } ["snow_allday"]=> array(2) { ["in"]=> int(0) ["cm"]=> int(0) } ["snow_day"]=> array(2) { ["in"]=> int(0) ["cm"]=> int(0) } ["snow_night"]=> array(2) { ["in"]=> int(0) ["cm"]=> int(0) } ["maxwind"]=> array(4) { ["mph"]=> int(10) ["kph"]=> int(16) ["dir"]=> string(4) "מע" ["degrees"]=> int(265) } ["avewind"]=> array(4) { ["mph"]=> int(9) ["kph"]=> int(14) ["dir"]=> string(4) "מע" ["degrees"]=> int(265) } ["avehumidity"]=> int(56) ["maxhumidity"]=> int(0) ["minhumidity"]=> int(0) } Fatal error: Call to undefined function json_last_error() in /in/KL9XC on line 90
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Call to undefined function json_decode() in /in/KL9XC on line 85
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_decode() in /in/KL9XC on line 85
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: json_decode() in /in/KL9XC on line 85
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_decode() in /in/KL9XC on line 85

preferences:
261.96 ms | 401 KiB | 350 Q