json_decode_error.phpt 844 B

123456789101112131415161718192021222324252627282930
  1. --TEST--
  2. Test json_decode() function : error conditions
  3. --SKIPIF--
  4. <?php if (!extension_loaded("json")) print "skip"; ?>
  5. --FILE--
  6. <?php
  7. echo "*** Testing json_decode() : error conditions ***\n";
  8. echo "\n-- Testing json_decode() function with no arguments --\n";
  9. var_dump(json_decode());
  10. echo "\n-- Testing json_decode() function with more than expected no. of arguments --\n";
  11. $extra_arg = 10;
  12. var_dump(json_decode('"abc"', true, 512, 0, $extra_arg));
  13. ?>
  14. ===Done===
  15. --EXPECTF--
  16. *** Testing json_decode() : error conditions ***
  17. -- Testing json_decode() function with no arguments --
  18. Warning: json_decode() expects at least 1 parameter, 0 given in %s on line %d
  19. NULL
  20. -- Testing json_decode() function with more than expected no. of arguments --
  21. Warning: json_decode() expects at most 4 parameters, 5 given in %s on line %d
  22. NULL
  23. ===Done===