xref: /php-src/ext/filter/tests/010.phpt (revision bf94010b)
1--TEST--
2filter_var()
3--INI--
4precision=14
5--EXTENSIONS--
6filter
7--FILE--
8<?php
9
10var_dump(filter_var(array(1,"1","", "-23234", "text", "asdf234asdfgs", array()), FILTER_VALIDATE_INT, FILTER_REQUIRE_ARRAY));
11var_dump(filter_var(array(1.2,"1.7","", "-23234.123", "text", "asdf234.2asdfgs", array()), FILTER_VALIDATE_FLOAT, FILTER_REQUIRE_ARRAY));
12var_dump(filter_var(1, FILTER_SANITIZE_SPECIAL_CHARS, 1));
13var_dump(filter_var(1, FILTER_SANITIZE_SPECIAL_CHARS, 0));
14var_dump(filter_var(1, FILTER_SANITIZE_SPECIAL_CHARS, array()));
15var_dump(filter_var(1, -1, array(123)));
16var_dump(filter_var(1, 0, array()));
17
18echo "Done\n";
19?>
20--EXPECTF--
21array(7) {
22  [0]=>
23  int(1)
24  [1]=>
25  int(1)
26  [2]=>
27  bool(false)
28  [3]=>
29  int(-23234)
30  [4]=>
31  bool(false)
32  [5]=>
33  bool(false)
34  [6]=>
35  array(0) {
36  }
37}
38array(7) {
39  [0]=>
40  float(1.2)
41  [1]=>
42  float(1.7)
43  [2]=>
44  bool(false)
45  [3]=>
46  float(-23234.123)
47  [4]=>
48  bool(false)
49  [5]=>
50  bool(false)
51  [6]=>
52  array(0) {
53  }
54}
55string(1) "1"
56string(1) "1"
57string(1) "1"
58
59Warning: filter_var(): Unknown filter with ID -1 in %s on line %d
60bool(false)
61
62Warning: filter_var(): Unknown filter with ID 0 in %s on line %d
63bool(false)
64Done
65