1--TEST-- 2Hash: hash() function : error conditions 3--FILE-- 4<?php 5 6/* Prototype : string hash ( string $algo , string $data [, bool $raw_output ] ) 7 * Description: Generate a hash value (message digest) 8 * Source code: ext/hash/hash.c 9 * Alias to functions: 10*/ 11echo "*** Testing hash() : error conditions ***\n"; 12 13echo "\n-- Testing hash() function with less than expected no. of arguments --\n"; 14var_dump(hash()); 15var_dump(hash('adler32')); 16 17echo "\n-- Testing hash() function with more than expected no. of arguments --\n"; 18$extra_arg= 10; 19var_dump(hash('adler32', '', false, $extra_arg)); 20 21echo "\n-- Testing hash() function with invalid hash algorithm --\n"; 22var_dump(hash('foo', '')); 23 24?> 25===Done=== 26--EXPECTF-- 27*** Testing hash() : error conditions *** 28 29-- Testing hash() function with less than expected no. of arguments -- 30 31Warning: hash() expects at least 2 parameters, 0 given in %s on line %d 32NULL 33 34Warning: hash() expects at least 2 parameters, 1 given in %s on line %d 35NULL 36 37-- Testing hash() function with more than expected no. of arguments -- 38 39Warning: hash() expects at most 3 parameters, 4 given in %s on line %d 40NULL 41 42-- Testing hash() function with invalid hash algorithm -- 43 44Warning: hash(): Unknown hashing algorithm: foo in %s on line %d 45bool(false) 46===Done=== 47