007.phpt 820 B

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