json_encode_error.phpt 765 B

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