3v4l.org

run code in 300+ PHP versions simultaneously
<?php ob_start(); //simulating a JSON output ?> { "date": { "epoch": "1413388800", "pretty": "07:00 PM IDT , אוקטובר 15, 2014", "day": 15, "month": 10, "year": 2014, "yday": 287, "hour": 19, "min": "00", "sec": 0, "isdst": "1", "monthname": "אוקטובר", "monthname_short": "אוק", "weekday_short": "רביעי", "weekday": "רביעי", "ampm": "PM", "tz_short": "IDT", "tz_long": "Asia/Jerusalem" }, "period": 7, "high": { "fahrenheit": "78", "celsius": "26" }, "low": { "fahrenheit": "62", "celsius": "17" }, "conditions": "בהיר", "icon": "clear", "icon_url": "http://icons.wxug.com/i/c/k/clear.gif", "skyicon": "", "pop": 20, "qpf_allday": { "in": 0.03, "mm": 1 }, "qpf_day": { "in": 0, "mm": 0 }, "qpf_night": { "in": 0.03, "mm": 1 }, "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": 248 }, "avewind": { "mph": 10, "kph": 16, "dir": "מע-ד-מע", "degrees": 248 }, "avehumidity": 63, "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.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 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.18, 8.3.0 - 8.3.4, 8.3.6
array(20) { ["date"]=> array(17) { ["epoch"]=> string(10) "1413388800" ["pretty"]=> string(38) "07:00 PM IDT , אוקטובר 15, 2014" ["day"]=> int(15) ["month"]=> int(10) ["year"]=> int(2014) ["yday"]=> int(287) ["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(7) ["high"]=> array(2) { ["fahrenheit"]=> string(2) "78" ["celsius"]=> string(2) "26" } ["low"]=> array(2) { ["fahrenheit"]=> string(2) "62" ["celsius"]=> string(2) "17" } ["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(20) ["qpf_allday"]=> array(2) { ["in"]=> float(0.03) ["mm"]=> int(1) } ["qpf_day"]=> array(2) { ["in"]=> int(0) ["mm"]=> int(0) } ["qpf_night"]=> array(2) { ["in"]=> float(0.03) ["mm"]=> int(1) } ["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(12) "מע-ד-מע" ["degrees"]=> int(248) } ["avewind"]=> array(4) { ["mph"]=> int(10) ["kph"]=> int(16) ["dir"]=> string(12) "מע-ד-מע" ["degrees"]=> int(248) } ["avehumidity"]=> int(63) ["maxhumidity"]=> int(0) ["minhumidity"]=> int(0) } - No errorserrore No error
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 array(20) { ["date"]=> array(17) { ["epoch"]=> string(10) "1413388800" ["pretty"]=> string(38) "07:00 PM IDT , אוקטובר 15, 2014" ["day"]=> int(15) ["month"]=> int(10) ["year"]=> int(2014) ["yday"]=> int(287) ["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(7) ["high"]=> array(2) { ["fahrenheit"]=> string(2) "78" ["celsius"]=> string(2) "26" } ["low"]=> array(2) { ["fahrenheit"]=> string(2) "62" ["celsius"]=> string(2) "17" } ["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(20) ["qpf_allday"]=> array(2) { ["in"]=> float(0.03) ["mm"]=> int(1) } ["qpf_day"]=> array(2) { ["in"]=> int(0) ["mm"]=> int(0) } ["qpf_night"]=> array(2) { ["in"]=> float(0.03) ["mm"]=> int(1) } ["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(12) "מע-ד-מע" ["degrees"]=> int(248) } ["avewind"]=> array(4) { ["mph"]=> int(10) ["kph"]=> int(16) ["dir"]=> string(12) "מע-ד-מע" ["degrees"]=> int(248) } ["avehumidity"]=> int(63) ["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) "1413388800" ["pretty"]=> string(38) "07:00 PM IDT , אוקטובר 15, 2014" ["day"]=> int(15) ["month"]=> int(10) ["year"]=> int(2014) ["yday"]=> int(287) ["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(7) ["high"]=> array(2) { ["fahrenheit"]=> string(2) "78" ["celsius"]=> string(2) "26" } ["low"]=> array(2) { ["fahrenheit"]=> string(2) "62" ["celsius"]=> string(2) "17" } ["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(20) ["qpf_allday"]=> array(2) { ["in"]=> float(0.03) ["mm"]=> int(1) } ["qpf_day"]=> array(2) { ["in"]=> int(0) ["mm"]=> int(0) } ["qpf_night"]=> array(2) { ["in"]=> float(0.03) ["mm"]=> int(1) } ["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(12) "מע-ד-מע" ["degrees"]=> int(248) } ["avewind"]=> array(4) { ["mph"]=> int(10) ["kph"]=> int(16) ["dir"]=> string(12) "מע-ד-מע" ["degrees"]=> int(248) } ["avehumidity"]=> int(63) ["maxhumidity"]=> int(0) ["minhumidity"]=> int(0) } - No errors Fatal error: Call to undefined function json_last_error_msg() in /in/Sc663 on line 113
Process exited with code 255.
Output for 5.2.0 - 5.2.17
array(20) { ["date"]=> array(17) { ["epoch"]=> string(10) "1413388800" ["pretty"]=> string(38) "07:00 PM IDT , אוקטובר 15, 2014" ["day"]=> int(15) ["month"]=> int(10) ["year"]=> int(2014) ["yday"]=> int(287) ["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(7) ["high"]=> array(2) { ["fahrenheit"]=> string(2) "78" ["celsius"]=> string(2) "26" } ["low"]=> array(2) { ["fahrenheit"]=> string(2) "62" ["celsius"]=> string(2) "17" } ["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(20) ["qpf_allday"]=> array(2) { ["in"]=> float(0.03) ["mm"]=> int(1) } ["qpf_day"]=> array(2) { ["in"]=> int(0) ["mm"]=> int(0) } ["qpf_night"]=> array(2) { ["in"]=> float(0.03) ["mm"]=> int(1) } ["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(12) "מע-ד-מע" ["degrees"]=> int(248) } ["avewind"]=> array(4) { ["mph"]=> int(10) ["kph"]=> int(16) ["dir"]=> string(12) "מע-ד-מע" ["degrees"]=> int(248) } ["avehumidity"]=> int(63) ["maxhumidity"]=> int(0) ["minhumidity"]=> int(0) } Fatal error: Call to undefined function json_last_error() in /in/Sc663 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/Sc663 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/Sc663 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/Sc663 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/Sc663 on line 85

preferences:
216.22 ms | 401 KiB | 312 Q