xref: /PHP-8.1/ext/filter/tests/036.phpt (revision 74859783)
1--TEST--
2filter_var_array() and references
3--EXTENSIONS--
4filter
5--FILE--
6<?php
7
8$var = "1";
9
10$data = array();
11$data["test1"] = 1;
12$data["test2"] = &$var;
13
14$args = array();
15$args["test1"] = FILTER_VALIDATE_INT;
16$args["test2"] = FILTER_VALIDATE_INT;
17
18$ret = filter_var_array($data, $args);
19var_dump($ret);
20var_dump($data); //should be separated, i.e. not reference anymore. looks like we can't change this, or it'd change the original zval instead..
21var_dump($var); //should be still string(1) "1"
22
23echo "Done\n";
24?>
25--EXPECT--
26array(2) {
27  ["test1"]=>
28  int(1)
29  ["test2"]=>
30  int(1)
31}
32array(2) {
33  ["test1"]=>
34  int(1)
35  ["test2"]=>
36  &string(1) "1"
37}
38string(1) "1"
39Done
40