xref: /PHP-8.2/ext/filter/tests/052.phpt (revision bf94010b)
1--TEST--
2filter_var() / filter_var_array() and passed data integrity
3--EXTENSIONS--
4filter
5--FILE--
6<?php
7function filter_cb($var)
8{
9  return 1;
10}
11
12$data = array ('bar' => array ('fu<script>bar', 'bar<script>fu') );
13var_dump(filter_var($data, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FORCE_ARRAY));
14var_dump($data);
15var_dump(filter_var($data, FILTER_CALLBACK, array('options' => 'filter_cb')));
16var_dump($data);
17var_dump(filter_var_array($data, array('bar' => array('filter' => FILTER_CALLBACK, 'options' => 'filter_cb'))));
18var_dump($data);
19?>
20--EXPECT--
21array(1) {
22  ["bar"]=>
23  array(2) {
24    [0]=>
25    string(21) "fu&#60;script&#62;bar"
26    [1]=>
27    string(21) "bar&#60;script&#62;fu"
28  }
29}
30array(1) {
31  ["bar"]=>
32  array(2) {
33    [0]=>
34    string(13) "fu<script>bar"
35    [1]=>
36    string(13) "bar<script>fu"
37  }
38}
39array(1) {
40  ["bar"]=>
41  array(2) {
42    [0]=>
43    int(1)
44    [1]=>
45    int(1)
46  }
47}
48array(1) {
49  ["bar"]=>
50  array(2) {
51    [0]=>
52    string(13) "fu<script>bar"
53    [1]=>
54    string(13) "bar<script>fu"
55  }
56}
57array(1) {
58  ["bar"]=>
59  array(2) {
60    [0]=>
61    int(1)
62    [1]=>
63    int(1)
64  }
65}
66array(1) {
67  ["bar"]=>
68  array(2) {
69    [0]=>
70    string(13) "fu<script>bar"
71    [1]=>
72    string(13) "bar<script>fu"
73  }
74}
75