1--TEST-- 2Test json_decode() function : error conditions 3--SKIPIF-- 4<?php 5if (!extension_loaded("json")) { 6 die('skip JSON extension not available in this build'); 7} 8?> 9--FILE-- 10<?php 11/* Prototype : mixed json_decode ( string $json [, bool $assoc=false [, int $depth=512 ]] ) 12 * Description: Decodes a JSON string 13 * Source code: ext/json/php_json.c 14 * Alias to functions: 15 */ 16echo "*** Testing json_decode() : error conditions ***\n"; 17 18echo "\n-- Testing json_decode() function with no arguments --\n"; 19var_dump( json_decode() ); 20 21echo "\n-- Testing json_decode() function with more than expected no. of arguments --\n"; 22$extra_arg = 10; 23var_dump( json_decode('"abc"', TRUE, 512, 0, $extra_arg) ); 24 25?> 26===Done=== 27--EXPECTF-- 28*** Testing json_decode() : error conditions *** 29 30-- Testing json_decode() function with no arguments -- 31 32Warning: json_decode() expects at least 1 parameter, 0 given in %s on line %d 33NULL 34 35-- Testing json_decode() function with more than expected no. of arguments -- 36 37Warning: json_decode() expects at most 4 parameters, 5 given in %s on line %d 38NULL 39===Done=== 40