xref: /PHP-5.4/ext/filter/tests/032.phpt (revision 2c3db736)
1--TEST--
2input_get_args()
3--SKIPIF--
4<?php if (!extension_loaded("filter")) die("skip"); ?>
5--FILE--
6<?php
7$data = array(
8    'product_id'    => 'libgd<script>',
9    'component'     => '10dhsajkkdhk <do>',
10    'versions'      => '2.0.33',
11    'testscalar'    => array('2','23','10','12'),
12    'testarray'     => '2',
13);
14
15$args = array(
16    'product_id'    => FILTER_SANITIZE_ENCODED,
17    'component'     => array(//'filter' => FILTER_VALIDATE_INT,
18                             'flags'    => FILTER_FORCE_ARRAY,
19                             'options'  => array("min_range"=>1, "max_range"=>10)
20                        ),
21    'versions'      => array(
22                            'filter' => FILTER_SANITIZE_ENCODED,
23                            'flags'  => FILTER_REQUIRE_SCALAR,
24                            ),
25    'doesnotexist'  => FILTER_VALIDATE_INT,
26    'testscalar'    => FILTER_VALIDATE_INT,
27    'testarray' => array(
28                            'filter' => FILTER_VALIDATE_INT,
29                            'flags'  => FILTER_FORCE_ARRAY,
30                        )
31
32);
33
34$myinputs = filter_var_array($data, $args);
35var_dump($myinputs);
36?>
37--EXPECT--
38array(6) {
39  ["product_id"]=>
40  string(17) "libgd%3Cscript%3E"
41  ["component"]=>
42  array(1) {
43    [0]=>
44    string(17) "10dhsajkkdhk <do>"
45  }
46  ["versions"]=>
47  string(6) "2.0.33"
48  ["doesnotexist"]=>
49  NULL
50  ["testscalar"]=>
51  bool(false)
52  ["testarray"]=>
53  array(1) {
54    [0]=>
55    int(2)
56  }
57}
58