xref: /PHP-8.1/ext/filter/tests/040.phpt (revision 74859783)
1--TEST--
2filter_has_var() tests
3--EXTENSIONS--
4filter
5--GET--
6a=1&b=2&c=0
7--POST--
8ap[]=1&bp=test&cp=
9--FILE--
10<?php
11
12var_dump(filter_has_var(INPUT_GET,""));
13var_dump(filter_has_var(INPUT_POST, "ap"));
14var_dump(filter_has_var(INPUT_POST, "cp"));
15var_dump(filter_has_var(INPUT_GET, "a"));
16var_dump(filter_has_var(INPUT_GET, "c"));
17var_dump(filter_has_var(INPUT_GET, "abc"));
18var_dump(filter_has_var(INPUT_GET, "cc"));
19try {
20    filter_has_var(-1, "cc");
21} catch (ValueError $exception) {
22    echo $exception->getMessage() . "\n";
23}
24
25var_dump(filter_has_var(0, "cc"));
26
27echo "Done\n";
28?>
29--EXPECT--
30bool(false)
31bool(true)
32bool(true)
33bool(true)
34bool(true)
35bool(false)
36bool(false)
37filter_has_var(): Argument #1 ($input_type) must be an INPUT_* constant
38bool(false)
39Done
40