1--TEST-- 2json_last_error() tests 3--SKIPIF-- 4<?php if (!extension_loaded("json")) print "skip"; ?> 5--FILE-- 6<?php 7var_dump(json_decode("[1]")); 8var_dump(json_last_error(), json_last_error_msg()); 9var_dump(json_decode("[[1]]", false, 2)); 10var_dump(json_last_error(), json_last_error_msg()); 11var_dump(json_decode("[1}")); 12var_dump(json_last_error(), json_last_error_msg()); 13var_dump(json_decode('["' . chr(0) . 'abcd"]')); 14var_dump(json_last_error(), json_last_error_msg()); 15var_dump(json_decode("[1")); 16var_dump(json_last_error(), json_last_error_msg()); 17 18 19echo "Done\n"; 20?> 21--EXPECT-- 22array(1) { 23 [0]=> 24 int(1) 25} 26int(0) 27string(8) "No error" 28NULL 29int(1) 30string(28) "Maximum stack depth exceeded" 31NULL 32int(2) 33string(42) "State mismatch (invalid or malformed JSON)" 34NULL 35int(3) 36string(53) "Control character error, possibly incorrectly encoded" 37NULL 38int(4) 39string(12) "Syntax error" 40Done 41