3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php ob_start(); //simulating a JSON output ?> { "date": { "epoch": "1413561600", "pretty": "07:00 PM IDT , אוקטובר 17, 2014", "day": 17, "month": 10, "year": 2014, "yday": 289, "hour": 19, "min": "00", "sec": 0, "isdst": "1", "monthname": "אוקטובר", "monthname_short": "אוק", "weekday_short": "שישי", "weekday": "שישי", "ampm": "PM", "tz_short": "IDT", "tz_long": "Asia/Jerusalem" }, "period": 9, "high": { "fahrenheit": "83", "celsius": "28" }, "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": 15, "kph": 24, "dir": "צ", "degrees": 349 }, "avewind": { "mph": 10, "kph": 16, "dir": "צ", "degrees": 349 }, "avehumidity": 53, "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"; ?>
based on KL9XC
Output for 5.5.24 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(20) { ["date"]=> array(17) { ["epoch"]=> string(10) "1413561600" ["pretty"]=> string(38) "07:00 PM IDT , אוקטובר 17, 2014" ["day"]=> int(17) ["month"]=> int(10) ["year"]=> int(2014) ["yday"]=> int(289) ["hour"]=> int(19) ["min"]=> string(2) "00" ["sec"]=> int(0) ["isdst"]=> string(1) "1" ["monthname"]=> string(14) "אוקטובר" ["monthname_short"]=> string(6) "אוק" ["weekday_short"]=> string(8) "שישי" ["weekday"]=> string(8) "שישי" ["ampm"]=> string(2) "PM" ["tz_short"]=> string(3) "IDT" ["tz_long"]=> string(14) "Asia/Jerusalem" } ["period"]=> int(9) ["high"]=> array(2) { ["fahrenheit"]=> string(2) "83" ["celsius"]=> string(2) "28" } ["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(15) ["kph"]=> int(24) ["dir"]=> string(2) "צ" ["degrees"]=> int(349) } ["avewind"]=> array(4) { ["mph"]=> int(10) ["kph"]=> int(16) ["dir"]=> string(2) "צ" ["degrees"]=> int(349) } ["avehumidity"]=> int(53) ["maxhumidity"]=> int(0) ["minhumidity"]=> int(0) } - No errorserrore No error
Output for 5.3.0 - 5.4.45
array(20) { ["date"]=> array(17) { ["epoch"]=> string(10) "1413561600" ["pretty"]=> string(38) "07:00 PM IDT , אוקטובר 17, 2014" ["day"]=> int(17) ["month"]=> int(10) ["year"]=> int(2014) ["yday"]=> int(289) ["hour"]=> int(19) ["min"]=> string(2) "00" ["sec"]=> int(0) ["isdst"]=> string(1) "1" ["monthname"]=> string(14) "אוקטובר" ["monthname_short"]=> string(6) "אוק" ["weekday_short"]=> string(8) "שישי" ["weekday"]=> string(8) "שישי" ["ampm"]=> string(2) "PM" ["tz_short"]=> string(3) "IDT" ["tz_long"]=> string(14) "Asia/Jerusalem" } ["period"]=> int(9) ["high"]=> array(2) { ["fahrenheit"]=> string(2) "83" ["celsius"]=> string(2) "28" } ["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(15) ["kph"]=> int(24) ["dir"]=> string(2) "צ" ["degrees"]=> int(349) } ["avewind"]=> array(4) { ["mph"]=> int(10) ["kph"]=> int(16) ["dir"]=> string(2) "צ" ["degrees"]=> int(349) } ["avehumidity"]=> int(53) ["maxhumidity"]=> int(0) ["minhumidity"]=> int(0) } - No errors Fatal error: Call to undefined function json_last_error_msg() in /in/qiA5O on line 113
Process exited with code 255.
Output for 5.2.0 - 5.2.17
array(20) { ["date"]=> array(17) { ["epoch"]=> string(10) "1413561600" ["pretty"]=> string(38) "07:00 PM IDT , אוקטובר 17, 2014" ["day"]=> int(17) ["month"]=> int(10) ["year"]=> int(2014) ["yday"]=> int(289) ["hour"]=> int(19) ["min"]=> string(2) "00" ["sec"]=> int(0) ["isdst"]=> string(1) "1" ["monthname"]=> string(14) "אוקטובר" ["monthname_short"]=> string(6) "אוק" ["weekday_short"]=> string(8) "שישי" ["weekday"]=> string(8) "שישי" ["ampm"]=> string(2) "PM" ["tz_short"]=> string(3) "IDT" ["tz_long"]=> string(14) "Asia/Jerusalem" } ["period"]=> int(9) ["high"]=> array(2) { ["fahrenheit"]=> string(2) "83" ["celsius"]=> string(2) "28" } ["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(15) ["kph"]=> int(24) ["dir"]=> string(2) "צ" ["degrees"]=> int(349) } ["avewind"]=> array(4) { ["mph"]=> int(10) ["kph"]=> int(16) ["dir"]=> string(2) "צ" ["degrees"]=> int(349) } ["avehumidity"]=> int(53) ["maxhumidity"]=> int(0) ["minhumidity"]=> int(0) } Fatal error: Call to undefined function json_last_error() in /in/qiA5O on line 90
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function json_decode() in /in/qiA5O 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/qiA5O on line 85
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: json_decode() in /in/qiA5O 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/qiA5O on line 85