Return to array_slice_error.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / array |
1.1 misho 1: --TEST-- 2: Test array_slice() function : error conditions - Pass incorrect number of args 3: --FILE-- 4: <?php 5: /* Prototype : array array_slice(array $input, int $offset [, int $length [, bool $preserve_keys]]) 6: * Description: Returns elements specified by offset and length 7: * Source code: ext/standard/array.c 8: */ 9: 10: /* 11: * Pass an incorrect number of arguments to array_slice() to test behaviour 12: */ 13: 14: echo "*** Testing array_slice() : error conditions ***\n"; 15: 16: //Test array_slice with one more than the expected number of arguments 17: echo "\n-- Testing array_slice() function with more than expected no. of arguments --\n"; 18: $input = array(1, 2); 19: $offset = 10; 20: $length = 10; 21: $preserve_keys = true; 22: $extra_arg = 10; 23: var_dump( array_slice($input, $offset, $length, $preserve_keys, $extra_arg) ); 24: 25: // Testing array_slice with one less than the expected number of arguments 26: echo "\n-- Testing array_slice() function with less than expected no. of arguments --\n"; 27: var_dump( array_slice($input) ); 28: 29: echo "Done"; 30: ?> 31: --EXPECTF-- 32: *** Testing array_slice() : error conditions *** 33: 34: -- Testing array_slice() function with more than expected no. of arguments -- 35: 36: Warning: array_slice() expects at most 4 parameters, 5 given in %s on line %d 37: NULL 38: 39: -- Testing array_slice() function with less than expected no. of arguments -- 40: 41: Warning: array_slice() expects at least 2 parameters, 1 given in %s on line %d 42: NULL 43: Done