1--TEST--
2Test gethostbyaddr() function : error conditions
3--FILE--
4<?php
5/* Prototype  : proto string gethostbyaddr(string ip_address)
6 * Description: Get the Internet host name corresponding to a given IP address
7 * Source code: ext/standard/dns.c
8 * Alias to functions:
9 */
10
11
12echo "Testing gethostbyaddr : error conditions\n";
13
14// Zero arguments
15echo "\n-- Testing gethostbyaddr function with Zero arguments --\n";
16var_dump( gethostbyaddr() );
17
18//Test gethostbyaddr with one more than the expected number of arguments
19echo "\n-- Testing gethostbyaddr function with more than expected no. of arguments --\n";
20$ip_address = 'string_val';
21$extra_arg = 10;
22var_dump( gethostbyaddr($ip_address, $extra_arg) );
23
24echo "\n-- Testing gethostbyaddr function with invalid addresses --\n";
25
26$ip_address = 'invalid';
27var_dump( gethostbyaddr($ip_address) );
28
29$ip_address = '300.1.2.3';
30var_dump( gethostbyaddr($ip_address) );
31
32$ip_address = '256.1.2.3';
33var_dump( gethostbyaddr($ip_address) );
34
35echo "Done";
36?>
37--EXPECTREGEX--
38Testing gethostbyaddr : error conditions
39
40-- Testing gethostbyaddr function with Zero arguments --
41
42Warning: gethostbyaddr\(\) expects exactly 1 parameter, 0 given in .* on line \d+
43NULL
44
45-- Testing gethostbyaddr function with more than expected no. of arguments --
46
47Warning: gethostbyaddr\(\) expects exactly 1 parameter, 2 given in .* on line \d+
48NULL
49
50-- Testing gethostbyaddr function with invalid addresses --
51
52Warning: gethostbyaddr\(\): Address is not (in a.b.c.d form|a valid IPv4 or IPv6 address) in .* on line \d+
53bool\(false\)
54
55Warning: gethostbyaddr\(\): Address is not (in a.b.c.d form|a valid IPv4 or IPv6 address) in .* on line \d+
56bool\(false\)
57
58Warning: gethostbyaddr\(\): Address is not (in a.b.c.d form|a valid IPv4 or IPv6 address) in .* on line \d+
59bool\(false\)
60Done
61